https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116742
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2024-09-17
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that 'n' is address taken and escapes:
<bb 2> :
std::ios_base::sync_with_stdio (0);
<bb 3> :
std::basic_ios<char>::tie (&cin.D.48191, 0B);
s_6 = n;
std::basic_istream<char>::operator>> (&cin, &n);
<bb 4> :
_9 = std::basic_ostream<char>::operator<< (&cout, s_6);
we thus consider that for example std::ios_base::sync_with_stdio might
initialize 'n' since we lose the fact that 'n' only becomes live after that
call. The C++ frontend does not add explicit scopes for
int n, s = n;
so it doesn't get CLOBBER treatment. Adding scopes doesn't help either
(the gimplifier doesn't add CLOBBERs for start-of-live).