| 1 |
// PR c++/50060 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
extern "C" double frexp (double, int *); |
| 5 |
|
| 6 |
struct S |
| 7 |
{ |
| 8 |
constexpr S (double a) : y {}, x (frexp (a, &y)) {} // { dg-error "is not a constant expression" "S" { target { ! c++14 } } } |
| 9 |
double x; |
| 10 |
int y; |
| 11 |
}; |
| 12 |
|
| 13 |
struct T |
| 14 |
{ |
| 15 |
constexpr T (double a) : y {}, x ((y = 1, 0.8125)) {} // { dg-error "is not a constant expression" "T" { target { ! c++14 } } } |
| 16 |
double x; |
| 17 |
int y; |
| 18 |
}; |
| 19 |
|
| 20 |
static_assert (S (6.5).x == 0.8125, ""); // { dg-error "non-constant condition for static assertion|in .constexpr. expansion" "" { target { ! c++14 } } } |
| 21 |
static_assert (T (6.5).x == 0.8125, ""); // { dg-error "non-constant condition for static assertion|called in a constant expression" "" { target { ! c++14 } } } |