-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Closed
Copy link
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"lambdaC++11 lambda expressionsC++11 lambda expressions
Description
struct S {
template <class T>
S(T) {}
};
void foo() {
S s([a(42), &] {}); // Clang diagnoses 'capture default must be first' which is very clear
}However, if we initialize S with a brace initializer,
struct S {
template <class T>
S(T) {}
};
void foo() {
S s{[a(42), &] {}};
}Clang diagnoses
<source>:7:8: error: use of undeclared identifier 'a'
7 | S s{[a(42), &] {}};
| ^
<source>:7:13: error: expected ']'
7 | S s{[a(42), &] {}};
| ^
<source>:7:7: note: to match this '['
7 | S s{[a(42), &] {}};
| ^
<source>:7:7: warning: array designators are a C99 extension [-Wc99-designator]
7 | S s{[a(42), &] {}};
| ^~~~~~~~~~
for which clang does seem to parse it as an array designator and incurs confusing diagnostics.
See it on godbolt:
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"lambdaC++11 lambda expressionsC++11 lambda expressions