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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
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).

Reply via email to