Skip to content

Commit

Permalink
Fix false positive use-after-free error
Browse files Browse the repository at this point in the history
GCC flags this as an error due to the realloc before it.
  • Loading branch information
sogartar committed Aug 17, 2023
1 parent 0994f25 commit 5a62f59
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions runtime/src/iree/base/allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,17 @@ static iree_status_t iree_allocator_system_alloc(
}

if (existing_ptr) {
// When compiling On ARM64,
// GCC wrongly flags this as an error [-Werror=use-after-free]
// due to the realloc above.
#if defined(__GNUC__) && (__GNUC__ >= 7) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free"
#endif
IREE_TRACE_FREE(existing_ptr);
#if defined(__GNUC__) && (__GNUC__ >= 7) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
}
IREE_TRACE_ALLOC(new_ptr, byte_length);

Expand Down

0 comments on commit 5a62f59

Please sign in to comment.