| 1 |
// { dg-do run { target c++11 } } |
| 2 |
// PR c++/83160 failed to capture as lvalue |
| 3 |
|
| 4 |
int main () |
| 5 |
{ |
| 6 |
const int a = 0; |
| 7 |
|
| 8 |
if (![&a] (const int *p) |
| 9 |
{ |
| 10 |
const int &b = a; |
| 11 |
// We should bind to the outer a |
| 12 |
return &b == p; |
| 13 |
} (&a)) |
| 14 |
return 1; |
| 15 |
|
| 16 |
if (![&] (const int *p) |
| 17 |
{ |
| 18 |
const int &b = a; |
| 19 |
// We should bind to the outer a |
| 20 |
return &b == p; |
| 21 |
} (&a)) |
| 22 |
return 2; |
| 23 |
|
| 24 |
if ([=] (const int *p) |
| 25 |
{ |
| 26 |
const int &b = a; |
| 27 |
// We should bind to the captured instance |
| 28 |
return &b == p; |
| 29 |
}(&a)) |
| 30 |
return 3; |
| 31 |
|
| 32 |
return 0; |
| 33 |
} |