This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/78940] [missed optimization] Useless guard variable in thread_local defaulted constructor


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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Nadav Har'El from comment #1)
> I don't know why the standard decided that the default constructor should
> not be marked "constexpr", unlike the value-taking constructors.

Because the standard requires that the default constructor doesn't initialize
the value, for compatibility with "atomic_int i;" in C which leaves it
uninitialized. A constexpr constructor must not leave data uninitialized, so
they can't be constexpr if they're C-compatible.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]