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