https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110375
--- Comment #4 from Giuseppe D'Angelo <dangelog at gmail dot com> --- (In reply to Andrew Pinski from comment #3) > (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 That's not P2723R1's claim. Quoting: "We propose to zero-initialize all objects of automatic storage duration, making C++ safer by default. This was implemented as an opt-in compiler flag in 2018 for LLVM [LLVMReview] and MSVC [WinKernel], and 2021 in for GCC [GCCReview]." This report (and Clang's) shows that that's misleading. > 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. Fair enough; then, please, could this report be turned into a feature request for the C/C++ frontends?