Subject: bug#76559: 31.0.50; [-O3 + PGTK] Crash when 'copying as kill'/'killing word'

From: Pip Cet <[email-masked]>
Date: Sat, 01 Mar 2025 10:21:38 +0000

"Po Lu" <[email-masked]> writes:

> Pip Cet <[email-masked]> writes:
>
>> My understanding is it is safe to access an entire union at once, as the
>> old code did, and that GCC concluded based on the undefined behavior
>> elsewhere that the only possible union members were those with the holes
>> in the right place.
>
> BTW, if so, how do you explain this reproducer?  At no point in the
> code's execution is hold_quit ever read or written to.

That does seem to be an actual bug, where SRA does the wrong thing if a
function is marked with __attribute__ ((optimize (0))).  At first glance
(-fdump-tree-sra-details) it seems like the whole-structure access in
that function is ignored, which makes sense if the SRA pass isn't run
for a non-optimized function but still assumes it has looked at all
accesses.

So we should definitely report this (after reducing to a single file and
fixing the prototypes), and any of our suspicions about wrong behavior
for other code.

Please let us know the GCC bug number(s).

Pip