1 // PR 84497 mismatch with thread constructor fn weakness
2 // { dg-do compile { target c++11 } }
3 // { dg-require-weak "" }
4 // { dg-require-alias "" }
5 // { dg-skip-if "No .weak" { { hppa*-*-hpux* } && { ! lp64 } } }
6 
7 struct Base
8 {
9   int m;
10 
11   Base() noexcept = default;  // trivial but not constexpr
12   ~Base() noexcept = default;
13 };
14 
15 struct Derived : Base {};
16 struct Container {
17   Base m;
18 };
19 
20 #ifdef DEF
21 // This bit for exposition only.
22 // All items placed in .tbss
23 // __tls_init simply sets __tls_guard
24 // no aliases to __tls_init generated
25 thread_local Base base_obj;
26 thread_local Derived derived_obj;
27 thread_local Container container_obj;
28 #else
29 // Erroneously created strong undef refs to
30 // _ZTH11derived_obj, _ZTH13container_obj, _ZTH8base_obj
31 extern thread_local Base base_obj;
32 extern thread_local Derived derived_obj;
33 extern thread_local Container container_obj;
main()34 int main() { return !(&base_obj && &derived_obj && &container_obj);}
35 #endif
36 
37 // { dg-final { scan-assembler ".weak\[ \t\]*_ZTH8base_obj" } }
38 // { dg-final { scan-assembler ".weak\[ \t\]*_ZTH11derived_obj" } }
39 // { dg-final { scan-assembler ".weak\[ \t\]*_ZTH13container_obj" } }
40