https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117695
Tianyang Zhou <tianyang.chou at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tianyang.chou at gmail dot com --- Comment #9 from Tianyang Zhou <tianyang.chou at gmail dot com> --- (In reply to Andrew Pinski from comment #8) > so this code is undefined for a few different reasons. > #1 is you can't call fprintf from an async signal (e.g. SIGALARM). > https://www.gnu.org/software/libc/manual/html_node/Formatted-Output- > Functions.html > specifies that fprintf is `AS-Unsafe corrupt heap` > (https://www.gnu.org/software/libc/manual/html_node/POSIX-Safety-Concepts. > html for the meaning there on AS) > > > #2 is an async signal might be done at different times and the write might > not be done by the compiler at all, you need to mark the variable as > volatile. that is Run_Index needs to be marked as volatile to get the > variable written to by the compiler (that is why it is optimized away with > LTO). Hi Andrew, Instead of marking the variable as volatile. Will disable loop-eliminating related passes works for this circumstance?