aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/constexpr-union8.C
blob: 1e51857b3dff7fa2fb5dfff09c4195631396cbfc (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
30
31
// PR c++/117614
// { dg-do compile { target c++20 } }

constexpr int
foo ()
{
  union {
    int x{0};
    char y;
  };
  y = 1;
  return y;
}

constexpr int
bar ()
{
  union {
    union {
      int x{0};
      char y;
    };
    long long z;
  };
  y = 1;
  z = 2;
  return z;
}

static_assert (foo () == 1);
static_assert (bar () == 2);