From 5a62f59e2faa5fb4968106f3481e9939978f72fe Mon Sep 17 00:00:00 2001 From: Boian Petkantchin Date: Wed, 16 Aug 2023 19:28:36 -0700 Subject: [PATCH] Fix false positive use-after-free error GCC flags this as an error due to the realloc before it. --- runtime/src/iree/base/allocator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/runtime/src/iree/base/allocator.c b/runtime/src/iree/base/allocator.c index c162dd2bd7da..8c08882b0f8d 100644 --- a/runtime/src/iree/base/allocator.c +++ b/runtime/src/iree/base/allocator.c @@ -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);