| 1 |
// PR c++/91741 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-Wall" } |
| 4 |
|
| 5 |
int |
| 6 |
fn1 () |
| 7 |
{ |
| 8 |
int arr[10]; |
| 9 |
return sizeof (arr) / sizeof (decltype(arr[0])); |
| 10 |
} |
| 11 |
|
| 12 |
template<typename T, int N> |
| 13 |
int fn2 (T (&arr)[N]) |
| 14 |
{ |
| 15 |
return sizeof (arr) / sizeof (T); |
| 16 |
} |
| 17 |
|
| 18 |
template<typename T, int N> |
| 19 |
int fn3 (T (&arr)[N]) |
| 20 |
{ |
| 21 |
return sizeof (arr) / sizeof (bool); // { dg-warning "expression does not compute" } |
| 22 |
} |
| 23 |
|
| 24 |
template<typename U, int N, typename T> |
| 25 |
int fn4 (T (&arr)[N]) |
| 26 |
{ |
| 27 |
return sizeof (arr) / sizeof (U); // { dg-warning "expression does not compute" } |
| 28 |
} |
| 29 |
|
| 30 |
void |
| 31 |
fn () |
| 32 |
{ |
| 33 |
int arr[10]; |
| 34 |
fn2 (arr); |
| 35 |
fn3 (arr); |
| 36 |
fn4<short> (arr); |
| 37 |
} |