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++/58408] [C++11] __thread + trivially_constructible -> error


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

Nadav Har'El <nyh at math dot technion.ac.il> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nyh at math dot technion.ac.il

--- Comment #2 from Nadav Har'El <nyh at math dot technion.ac.il> ---
I don't think should be considered a bug. "__thread" doesn't get a chance to
run the object's constructor, so the constructor must be constexpr, meaning
that the compiler can figure out, in compile type, the string of bytes needed
to initialize this object, and put it proper section of the executable (the
standard C library then copies this TLS area for each new thread).

So you just need to mark your constructor "constexpr", and your code will work.

It is arguable that the compiler could figure out that your constructor *can
be* constexpr, even if you don't tell it that it is (since when you do tell it
is, it already has the machinary to verify), but I'm not sure why it is worth
the hassle?


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