<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>511972</bug_id>
          
          <creation_ts>2025-11-11 22:04:50 +0000</creation_ts>
          <short_desc>valgrind-3.26.0 tests fail to build on upcomig gcc-16: unrecognized command-line option &apos;-Wno-alloc-size-larger-than=18446744073709551615&apos;</short_desc>
          <delta_ts>2026-01-07 14:39:33 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>6</classification_id>
          <classification>Developer tools</classification>
          <product>valgrind</product>
          <component>general</component>
          <version>3.26 GIT</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Sergei Trofimovich">slyich</reporter>
          <assigned_to name="Paul Floyd">pjfloyd</assigned_to>
          <cc>mark</cc>
    
    <cc>pjfloyd</cc>
    
    <cc>sam</cc>
    
    <cc>slyich</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2469667</commentid>
    <comment_count>0</comment_count>
    <who name="Sergei Trofimovich">slyich</who>
    <bug_when>2025-11-11 22:04:50 +0000</bug_when>
    <thetext>SUMMARY

gcc-16 added extra validation to `-Wno-` options comared to `-W` options in https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=5b276d38c2fdd7df3d167755940da2038e049308

As a result `-Walloc-size-larger-than=18446744073709551615` is not valid flag while `-Wno-alloc-size-larger-than=18446744073709551615` is invalid and the build fails as:

gcc -DHAVE_CONFIG_H -I. -I../..  -I../.. -I../../include -I../../coregrind -I../../include -I../../VEX/pub -I../../VEX/pub -DVGA_amd64=1 -DVGO_linux=1 -DVGP_amd64_linux=1 -DVGPV_amd64_linux_vanilla=1    -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector   -m64 -Wno-unused-result -Wno-alloc-size-larger-than=18446744073709551615  -MT bug155125-bug155125.o -MD -MP -MF .deps/bug155125-bug155125.Tpo -c -o bug155125-bug155125.o `test -f &apos;bug155125.c&apos; || echo &apos;./&apos;`bug155125.c
gcc: error: unrecognized command-line option &apos;-Wno-alloc-size-larger-than=18446744073709551615&apos;

STEPS TO REPRODUCE
1. install `gcc` from `master`
2. $ ./configure CC=gcc-16 CXX=g++-16
3. $ make check

OBSERVED RESULT

Build fails with `gcc: error: unrecognized command-line option &apos;-Wno-alloc-size-larger-than=18446744073709551615&apos;`

EXPECTED RESULT

Build should succeed.

SOFTWARE/OS VERSIONS
compiler: gcc from master branch

ADDITIONAL INFORMATION

The bug happens because `configure.ac` only probes `-Walloc-size-larger-than=18446744073709551615` option and assumes `-Wno-alloc-size-larger-than=18446744073709551615` would work automatically:

From configure.ac:

```
AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
  AC_MSG_CHECKING([if gcc accepts -W$1])
  safe_CFLAGS=$CFLAGS
  CFLAGS=&quot;-W$1 -Werror&quot; dnl &lt;---------------- probe -W ===============
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
  AC_SUBST([$2], [-Wno-$1])  dnl &lt;---------------- assume -Wno- =========
  AC_MSG_RESULT([yes])], [
  AC_SUBST([$2], [])
  AC_MSG_RESULT([no])])
  CFLAGS=$safe_CFLAGS
])
...

AC_GCC_WARNING_SUBST_NO([alloc-size-larger-than=18446744073709551615], [FLAG_W_NO_ALLOC_SIZE_LARGER_THAN])
```

It used to work until https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=5b276d38c2fdd7df3d167755940da2038e049308

A simple workaround to check both forms of the flag restores the build for me:

```diff
--- a/configure.ac
+++ b/configure.ac
@@ -2538,7 +2538,7 @@ fi
 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
   AC_MSG_CHECKING([if gcc accepts -W$1])
   safe_CFLAGS=$CFLAGS
-  CFLAGS=&quot;-W$1 -Werror&quot;
+  CFLAGS=&quot;-W$1 -Wno-$1 -Werror&quot;
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
   AC_SUBST([$2], [-Wno-$1])
   AC_MSG_RESULT([yes])], [
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2469668</commentid>
    <comment_count>1</comment_count>
      <attachid>186714</attachid>
    <who name="Sergei Trofimovich">slyich</who>
    <bug_when>2025-11-11 22:09:22 +0000</bug_when>
    <thetext>Created attachment 186714
0001-bug-511972-check-for-both-W-and-Wno-warning-forms-gc.patch

0001-bug-511972-check-for-both-W-and-Wno-warning-forms-gc.patch implements `-W` / `-Wno-` option probing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2469676</commentid>
    <comment_count>2</comment_count>
    <who name="Sam James">sam</who>
    <bug_when>2025-11-11 23:41:37 +0000</bug_when>
    <thetext>*** Bug 511974 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2469731</commentid>
    <comment_count>3</comment_count>
    <who name="Paul Floyd">pjfloyd</who>
    <bug_when>2025-11-12 08:25:24 +0000</bug_when>
    <thetext>Does that now mean that GCC generates &quot;alloc size larger than&quot; warnings because it no longer supports &apos;-Wno-alloc-size-larger-than=18446744073709551615 ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2469753</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Wielaard">mark</who>
    <bug_when>2025-11-12 10:16:42 +0000</bug_when>
    <thetext>This feels like a regression in GCC. Why wouldn&apos;t it accept the -Wno variant that is accepted pre-gcc-16?
Might it just get fixed in GCC 16 (which is still a couple of months away) if we just report it against GCC?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2469862</commentid>
    <comment_count>5</comment_count>
    <who name="Paul Floyd">pjfloyd</who>
    <bug_when>2025-11-12 20:50:15 +0000</bug_when>
    <thetext>I&apos;ve changed the -Wno-alloc-size-larger-than=18446744073709551615 options to -Walloc-size-larger-than=18446744073709551616, which is more than the value that we are using (usually -1 converted to size_t). Seems to work with clang 19 and gcc 14.

commit 51c5973d9d1f096b9472df75638f2a53324fafed (HEAD -&gt; master, origin/master, origin/HEAD)
Author: Paul Floyd &lt;pjfloyd@wanadoo.fr&gt;
Date:   Wed Nov 12 21:46:23 2025 +0100

    Bug 511972 - valgrind-3.26.0 tests fail to build on upcomig gcc-16: unrecognized command-line option &apos;-Wno-alloc-size-larger-than=18446744073709551615&apos;
    
    Initial patch from Sergei Trofimovich, thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2469881</commentid>
    <comment_count>6</comment_count>
    <who name="Sergei Trofimovich">slyich</who>
    <bug_when>2025-11-12 22:08:08 +0000</bug_when>
    <thetext>(In reply to Mark Wielaard from comment #4)
&gt; This feels like a regression in GCC. Why wouldn&apos;t it accept the -Wno variant
&gt; that is accepted pre-gcc-16?
&gt; Might it just get fixed in GCC 16 (which is still a couple of months away)
&gt; if we just report it against GCC?

I think the change is intentional, but not sure. Added a comment to https://gcc.gnu.org/PR122243#c16.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2469887</commentid>
    <comment_count>7</comment_count>
    <who name="Sergei Trofimovich">slyich</who>
    <bug_when>2025-11-12 22:25:05 +0000</bug_when>
    <thetext>(In reply to Paul Floyd from comment #3)
&gt; Does that now mean that GCC generates &quot;alloc size larger than&quot; warnings
&gt; because it no longer supports
&gt; &apos;-Wno-alloc-size-larger-than=18446744073709551615 ?

Yeah, the original change resurfaced the warnings again. Your change still keeps it suppressed \o/

(In reply to Paul Floyd from comment #5)
&gt; I&apos;ve changed the -Wno-alloc-size-larger-than=18446744073709551615 options to
&gt; -Walloc-size-larger-than=18446744073709551616, which is more than the value
&gt; that we are using (usually -1 converted to size_t). Seems to work with clang
&gt; 19 and gcc 14.
&gt; 
&gt; commit 51c5973d9d1f096b9472df75638f2a53324fafed (HEAD -&gt; master,
&gt; origin/master, origin/HEAD)

Works for `gcc-16` as well. No alloc-size related warnings. Thank you!

The only new warning in `gcc-16` (unrelated to `-Wno-`) is:

new_override.cpp:21:16: warning: variable &apos;j&apos; set but not used [-Wunused-but-set-variable=]
   21 |   volatile int j = 0;
      |                ^

An effect of https://gcc.gnu.org/PR44677 ( https://gcc.gnu.org/r16-2258-g0eac9cfee8cb0b21d ).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2482628</commentid>
    <comment_count>8</comment_count>
    <who name="Mark Wielaard">mark</who>
    <bug_when>2026-01-07 14:39:33 +0000</bug_when>
    <thetext>Also backported to the VALGRIND_3_26_BRANCH as

commit fc9cf49c2f2e0e2282b000557df80ce2f755f191 (HEAD -&gt; VALGRIND_3_26_BRANCH)
Author: Paul Floyd &lt;pjfloyd@wanadoo.fr&gt;
Date:   Wed Nov 12 21:46:23 2025 +0100

    Bug 511972 - valgrind-3.26.0 tests fail to build on upcomig gcc-16: unrecognized command-line option &apos;-Wno-alloc-size-larger-than=18446744073709551615&apos;
    
    Initial patch from Sergei Trofimovich, thanks.
    
    (cherry picked from commit 51c5973d9d1f096b9472df75638f2a53324fafed)</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>186714</attachid>
            <date>2025-11-11 22:09:22 +0000</date>
            <delta_ts>2025-11-11 22:09:22 +0000</delta_ts>
            <desc>0001-bug-511972-check-for-both-W-and-Wno-warning-forms-gc.patch</desc>
            <filename>0001-bug-511972-check-for-both-W-and-Wno-warning-forms-gc.patch</filename>
            <type>text/plain</type>
            <size>1233</size>
            <attacher name="Sergei Trofimovich">slyich</attacher>
            
              <data encoding="base64">RnJvbSA0N2I0MGQ4NzgzNDVhZGI1YzNjNTA5YmQxYjkwYjJhNGUwOGIyYWM1IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBTZXJnZWkgVHJvZmltb3ZpY2ggPHNseWljaEBnbWFpbC5jb20+
CkRhdGU6IFR1ZSwgMTEgTm92IDIwMjUgMjI6MDU6MDcgKzAwMDAKU3ViamVjdDogW1BBVENIXSBi
dWcgNTExOTcyIC0gY2hlY2sgZm9yIGJvdGggLVcgYW5kIC1Xbm8tIHdhcm5pbmcgZm9ybXMKIChn
Y2MtMTYpCgpXaXRob3V0IHRoZSBjaGFuZ2UgYG1ha2UgY2hlY2tgIG9uIHVwY29taW5nIGBnY2Mt
MTZgIGZhaWxzIGFzOgoKICAgICQgbWFrZSBjaGVjawogICAgZ2NjOiBlcnJvcjogdW5yZWNvZ25p
emVkIGNvbW1hbmQtbGluZSBvcHRpb24gJy1Xbm8tYWxsb2Mtc2l6ZS1sYXJnZXItdGhhbj0xODQ0
Njc0NDA3MzcwOTU1MTYxNScKClRoaXMgaGFwcGVucyBiZWNhdXNlIGBnY2NgIHJlY2VudGx5IGlu
Y3JlYXNlZCBzdHJpY3RuZXNzIG9mIGAtV25vLWAgZmxhZ3MKY2hlY2tzIGluIGh0dHBzOi8vZ2Nj
LmdudS5vcmcvZ2l0Lz9wPWdjYy5naXQ7YT1jb21taXRkaWZmO2g9NWIyNzZkMzhjMmZkZDdkZjNk
MTY3NzU1OTQwZGEyMDM4ZTA0OTMwOAphbmQgc3RhcnRlZCByZWplY3RpbmcgYXJndW1lbnQgZm9y
IG9mIHRob3NlLgoKVGhlIGNoYW5nZSB2YWxpZGF0ZXMgYm90aCBgLVdgIGFuZCBgLVduby1gIGZv
cm1zIHRvIGF2b2lkIHBhc3NpbmcKdW50ZXN0ZWQgZmxhZ3MgdG8gdGhlIGNvbXBpb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