| 1 |
// PR c++/67445 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
#include <initializer_list> |
| 5 |
|
| 6 |
using SL = std::initializer_list<char const*>; |
| 7 |
|
| 8 |
SL retArray(int i) noexcept |
| 9 |
{ |
| 10 |
if (i == 0) |
| 11 |
{ |
| 12 |
SL l{"Test 1", "Test 2", "Test 3"}; // { dg-message "declared" } |
| 13 |
return l; // { dg-warning "initializer_list" } |
| 14 |
} |
| 15 |
else if (i == 1) |
| 16 |
return SL{"Test 1", "Test 2", "Test 3"}; // { dg-warning "initializer_list" } |
| 17 |
else if (i == 2) |
| 18 |
return {"Test 1", "Test 2", "Test 3"}; // { dg-warning "initializer_list" } |
| 19 |
else |
| 20 |
{ |
| 21 |
static SL l{"Test 1", "Test 2", "Test 3"}; |
| 22 |
return l; // no warning about returning static. |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
const char *p; |
| 27 |
int main(int, char const* const*) |
| 28 |
{ |
| 29 |
for (auto&& i : retArray(1)) |
| 30 |
{ |
| 31 |
p = i; |
| 32 |
} |
| 33 |
return 0; |
| 34 |
} |