[Bug c++/61991] Destructors not always called for statically initialized thread_local objects

2021-08-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61991

--- Comment #2 from Andrew Pinski  ---
GCC, clang and ICC all have this same behavior in that if y is not used, the y
is not initialized or deconstructed.

[Bug c++/61991] Destructors not always called for statically initialized thread_local objects

2015-07-10 Thread scovich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61991

--- Comment #1 from Ryan Johnson scovich at gmail dot com ---
C++14 (N3652 [1]) specifically alters the Standard to state that a thread_local
object with static or constexpr initialization may have a non-trivial
destructor (implying that such a destructor should actually run):

 Variables with static storage duration (3.7.1) or thread storage duration
 (3.7.2) shall be zero-initialized (8.5) before any other initialization takes
 place. A constant initializer for an object o is an expression that is a
 constant expression, except that it may also invoke constexpr constructors for
 o and its subobjects even if those objects are of non-literal class types
 [ Note: such a class may have a non-trivial destructor ].

[1] https://isocpp.org/files/papers/N3652.html