gcc/testsuite/g++.dg/template/anonunion3.C
raw| 1 | // PR c++/86182 |
| 2 | // { dg-do compile { target c++11 } } |
| 3 | |
| 4 | extern "C" int printf (const char *, ...); |
| 5 | |
| 6 | template<typename T> static char const * f(T *t) { |
| 7 | T u(*t); |
| 8 | u.x = "hello world"; |
| 9 | printf("%s\n", u.x); |
| 10 | return "initialized"; |
| 11 | } |
| 12 | |
| 13 | int main() { |
| 14 | union { char const *x = f(this); }; |
| 15 | printf("%s\n", x); |
| 16 | } |