gcc/testsuite/g++.dg/cpp1y/pr66735.C
raw| 1 | // { dg-do compile { target c++14 } } |
| 2 | |
| 3 | // PR c++/66735, lost constness on reference capture |
| 4 | |
| 5 | template <typename T> void Foo () |
| 6 | { |
| 7 | T const x = 5; |
| 8 | |
| 9 | auto l = [&rx = x]() {}; |
| 10 | |
| 11 | l (); |
| 12 | } |
| 13 | |
| 14 | void Baz () |
| 15 | { |
| 16 | int const x = 5; |
| 17 | auto l = [&rx = x]() {}; |
| 18 | |
| 19 | |
| 20 | l (); |
| 21 | Foo<int> (); |
| 22 | } |