ruby-changes:73851
From: Nobuyoshi <ko1@a...>
Date: Tue, 4 Oct 2022 21:54:21 +0900 (JST)
Subject: [ruby-changes:73851] 40ceceb1a5 (master): [Bug #19028] Suppress GCC 12 `-Wuse-after-free` false warning
https://git.ruby-lang.org/ruby.git/commit/?id=40ceceb1a5 From 40ceceb1a5b63029a4d1434d2d20dfa09cdb295f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 4 Oct 2022 10:54:28 +0900 Subject: [Bug #19028] Suppress GCC 12 `-Wuse-after-free` false warning GCC 12 introduced a new warning flag `-Wuse-after-free`, however it has a false positive at `realloc` when optimization is disabled, since the memory requested for reallocation is guaranteed to not be touched. This workaround is very unclear why the false warning is suppressed by a statement-expression GCC extension. --- gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 0ba28ba67b..c1b06a76e7 100644 --- a/gc.c +++ b/gc.c @@ -12236,7 +12236,7 @@ objspace_xrealloc(rb_objspace_t *objspace, void *ptr, size_t new_size, size_t ol https://github.com/ruby/ruby/blob/trunk/gc.c#L12236 #endif old_size = objspace_malloc_size(objspace, ptr, old_size); - TRY_WITH_GC(new_size, mem = realloc(ptr, new_size)); + TRY_WITH_GC(new_size, mem = RB_GNUC_EXTENSION_BLOCK(realloc(ptr, new_size))); new_size = objspace_malloc_size(objspace, mem, new_size); #if CALC_EXACT_MALLOC_SIZE -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/