On Sun, 15 Mar 2026 at 04:02 +0100, [email protected] wrote:
Good morning/afternoon/evening all. Long time user, first time caller here. I ran into this issue diagnosing some UB I had foolishly caused. Searched the bugzilla and found some related reports, but none identical to this situation so figured I should fire off an email at least.
This mailing list is for automated emails from our Bugzilla system, not for reporting bugs. Please use bugzilla to report bugs as described at https://gcc.gnu.org/bugs/ - thanks.
possibly related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107663 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106541 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100126 gcc_15_uninitialized.c: --- #include <stdio.h> struct Testing { int a; int b; }; void seemingly_unrelated(/*void*/) { printf("seemingly_unrelated(void) doesn't touch 'test' at all!\n"); } static int func(const struct Testing *test, const int b) { return test->a + b; } static int notmain() { // comment this line out to get the expected uninitialized warning seemingly_unrelated("side note:", " no warning here either"); struct Testing test; return func(&test, test.b); // uninitialized use of test.b // using two structs causes warning, as expected //struct Testing not_test; //return func(¬_test, test.b); } int main(void) { printf("bug won't happen in main()\n"); printf("a+b == %d\n", notmain()); return 0; } --- The warnings will be caught only when the function call to 'seemingly_unrelated' is removed. cmdline: gcc -O0 -g -pedantic -Wall -Wextra -Wconversion -Werror -o test gcc_15_uninitialized.c && ./test expected output: gcc_15_uninitialized.c:20:32: error: 'test.b' is used uninitialized [-Werror=uninitialized] gcc_15_uninitialized.c:20:16: error: 'test' may be used uninitialized [-Werror=maybe-uninitialized] config:Using built-in specs. COLLECT_GCC=gcc Target: x86_64-artax-linux-gnu Configured with: /home/builddir/gcc/gcc-15.2.0/configure --with-sysroot= --prefix=/artax --build=x86_64-artax-linux-gnu --host=x86_64-artax-linux-gnu --target=x86_64-artax-linux-gnu --with-local-prefix=/artax --with-native-system-header-dir=/artax/include --with-gxx-include-dir=/artax/include/c++ --enable-default-ssp --enable-threads=posix --enable-targets=all --enable-languages=c,c++ --disable-nls --disable-libsanitizer --disable-plugin --disable-bootstrap --disable-multilib --disable-lto Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.2.0 (GCC)
