| 1 |
// PR c++/49136 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-require-effective-target int32plus } |
| 4 |
|
| 5 |
struct S |
| 6 |
{ |
| 7 |
unsigned : 1; unsigned s : 27; unsigned : 4; |
| 8 |
constexpr S (unsigned int x) : s(x) {} |
| 9 |
}; |
| 10 |
|
| 11 |
template <typename S> |
| 12 |
struct T |
| 13 |
{ |
| 14 |
unsigned int t; |
| 15 |
constexpr T (S s) : t(s.s != 7 ? 0 : s.s) {} |
| 16 |
constexpr T (S s, S s2) : t(s.s != s2.s ? 0 : s.s) {} |
| 17 |
}; |
| 18 |
|
| 19 |
constexpr S s (7), s2 (7); |
| 20 |
constexpr T<S> t (s), t2 (s, s2); |
| 21 |
static_assert (t.t == 7, "Error"); |
| 22 |
static_assert (t2.t == 7, "Error"); |
| 23 |
|
| 24 |
struct U |
| 25 |
{ |
| 26 |
int a : 1; int s : 1; |
| 27 |
constexpr U (int x, int y) : a (x), s (y) {} |
| 28 |
}; |
| 29 |
|
| 30 |
constexpr U u (0, -1), u2 (-1, -1); |
| 31 |
constexpr T<U> t3 (u), t4 (u, u2); |
| 32 |
static_assert (t3.t == 0, "Error"); |
| 33 |
static_assert (t4.t == -1, "Error"); |