https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110375
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Giuseppe D'Angelo from comment #2) > (In reply to Andrew Pinski from comment #1) > > The code is undefined, > > Sure, although there are C++ proposals to make it well-defined / > implementatiopn-defined (see > https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2723r1.html and > https://isocpp.org/files/papers/P2795R1.html). > > But that's beside the point, I'm not claiming that the code does not have UB > -- although I'm not sure whether, if -ftrivial-auto-var-init is in use, an > optimizer stops considering such reads as UB. At least Clang stops: > https://gcc.godbolt.org/z/bKW5Mccsa But those proposals will be done in the front-end while -ftrivial-auto-var-init=zero is a generic non-front-end option. The middle-end will see the right thing and that option will not have an effect really. Note GCC with that option is not exactly undefined behavior but rather it is defined to be using that pattern. But what I was saying is rather it is the pattern 0 rather the 0.