summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/constexpr-bitfield2.C
blob: 531bf31fc01c950f0b4427f5456e981262e1e5c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// PR c++/49136
// { dg-do compile }
// { dg-options "-std=c++0x" }

struct day
{
  unsigned d : 5;
  unsigned n : 3;
  constexpr explicit day (int dd) : d(dd), n(7) {}
};

struct date {
  int d;
  constexpr date (day dd) : d(dd.n != 7 ? 7 : dd.d) {}
};

constexpr day d(0);
constexpr date dt(d);
static_assert (dt.d == 0, "Error");