[Clang] Capturing attribute argument on lambda throws error #59549
Closed
Description
void foo () {
constexpr int i = 2;
[&]() {
[=]() [[clang::annotate_type("test", i)]]{};
};
}<source>:5:42: error: variable 'i' cannot be implicitly captured in a lambda with no capture-default specified
[=]() [[clang::annotate_type("test", i)]]{};
^
<source>:2:17: note: 'i' declared here
constexpr int i = 2;Moving the captured variable to outer lambda scope fixes the error - https://godbolt.org/z/sPWx9aK5T
Capturing variable inside lambda body (instead of attribute argument) works - https://godbolt.org/z/z79jM9GMc
Activity