- Notifications
You must be signed in to change notification settings - Fork 15.1k
Description
| Bugzilla Link | 34749 |
| Resolution | DUPLICATE |
| Resolved on | Jan 30, 2018 16:30 |
| Version | 5.0 |
| OS | Linux |
| Blocks | #33840 #35152 |
| CC | @bebuch,@zygoloid,@tstellar |
Extended Description
#include
template < typename T >
void f(){
struct A{ T a; };
std::array< A, 1 > list{{{0}}};
for(auto [a]: list){
[a]{ (void)a;}
}
}
int main(){
f< int >();
}
should be a valid program, but:
$ clang++ -std=c++1z -stdlib=libc++ clang2.cpp -Wall
clang2.cpp:8:4: error: 'a' in capture list does not name a variable
[a]{ (void)a;}
^
clang2.cpp:8:14: error: reference to local binding 'a' declared in enclosing function 'f'
[a]{ (void)a;}
^
clang2.cpp:7:12: note: 'a' declared here
for(auto [a]: list){
^
clang2.cpp:8:17: error: expected ';' after expression
[a]{ (void)a;}
^
;
clang2.cpp:7:11: warning: unused variable '' [-Wunused-variable]
for(auto [a]: list){
^
clang2.cpp:13:2: note: in instantiation of function template specialization 'f' requested here
f< int >();
^
clang2.cpp:8:14: error: reference to local binding 'a' declared in enclosing function 'f'
[a]{ (void)a;}
^
clang2.cpp:7:12: note: 'a' declared here
for(auto [a]: list){
^
clang2.cpp:8:3: warning: expression result unused [-Wunused-value]
[a]{ (void)a;}
^~~~~~~~~~~~~~
2 warnings and 4 errors generated.
$ clang++ --version
clang version 6.0.0 (http://llvm.org/git/clang.git 58f82409fac6019a867e3b1bc5f6335e29c51b94) (http://llvm.org/git/llvm.git 9643e6b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Possibly related with Bug 34748