]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
malloc: Fix Os build on some ABIs
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Sat, 6 Sep 2025 22:21:35 +0000 (19:21 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 8 Sep 2025 11:21:48 +0000 (08:21 -0300)
I have not checked with all versions for all ABIs, but I saw failures
with gcc-14 on arm, alpha, hppa, i686, sparc, sh4, and microblaze.
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
malloc/malloc.c

index 6c02af5a271d21a40cfe199d118dd7e7ad886ed5..444dc618257d87c0373388c97f5f164164cc26ad 100644 (file)
@@ -3305,10 +3305,16 @@ tcache_get_align (size_t nb, size_t alignment)
           mangled = true;
         }
 
+      /* GCC compiling for -Os warns on some architectures that csize may be
+        uninitialized.  However, if 'te' is not NULL, csize is always
+        initialized in the loop above.  */
+      DIAG_PUSH_NEEDS_COMMENT;
+      DIAG_IGNORE_Os_NEEDS_COMMENT (12, "-Wmaybe-uninitialized");
       if (te != NULL
          && csize == nb
          && PTR_IS_ALIGNED (te, alignment))
        return tag_new_usable (tcache_get_n (tc_idx, tep, mangled));
+      DIAG_POP_NEEDS_COMMENT;
     }
   return NULL;
 }