summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/union1.C
blob: 9019c38a28543ea26a2809fb12bd3aaf47dfff34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// { dg-do run }

extern "C" void abort ();

void g (char c) 
{
  if (c != 'a')
    abort ();
}

void h (int i)
{
  if (i != 3)
    abort ();
}

template <typename T> void f(T const &t)
{
    union { char c; T t_; };

    c = 'a';
    g (c);
    t_ = 3;
    h (t_);
}

int main () {
  f (3);
}