https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108498

--- Comment #6 from Adam Stylinski <kungfujesus06 at gmail dot com> ---
(In reply to Richard Biener from comment #5)
> maybe a stack sharing issue?  Can you try -fstack-reuse=none?

So that does fix it, at least when the struct is backed by the stack.  And also
valgrind is no longer finding uninitialized memory being used:

adam@g5box ~ $ gcc -O2 -fstack-reuse=none bug_rep2.c -o test.out
adam@g5box ~ $ ./test.out 
sat? = 0

adam@g5box ~ $ valgrind ./test.out
==26982== Memcheck, a memory error detector
==26982== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==26982== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==26982== Command: ./test.out
==26982== 
sat? = 0
==26982== 
==26982== HEAP SUMMARY:
==26982==     in use at exit: 0 bytes in 0 blocks
==26982==   total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
==26982== 
==26982== All heap blocks were freed -- no leaks are possible
==26982== 
==26982== For lists of detected and suppressed errors, rerun with: -s
==26982== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Not sure what it might do if backed by the heap, but the code is written in a
way that it initializes the struct on the stack, anyway.

Reply via email to