[clang] [clang] Accept lambdas in C++03 as an extensions (PR #73376)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 2 06:51:58 PST 2023
================
@@ -92,14 +94,14 @@ namespace ImplicitCapture {
[] { return ref_i; }; // expected-error {{variable 'ref_i' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} expected-note 2 {{capture 'ref_i' by}} expected-note 2 {{default capture by}}
static int j;
- int &ref_j = j;
- [] { return ref_j; }; // ok
+ int &ref_j = j; // cxx03-fixme-note {{declared here}}
+ [] { return ref_j; }; // cxx03-fixme-error {{variable 'ref_j' cannot be implicitly captured in a lambda with no capture-default specified}} cxx03-fixme-note 4 {{capture}} cxx03-fixme-note {{lambda expression begins here}}
----------------
cor3ntin wrote:
`ref_j` is not odr-used because it is a reference whose initializer is itself a
usable in constant expressions (j is static and default initialized).
Because `ref_j` is not odr-used, it does not need to be captured.
https://eel.is/c++draft/expr.const#3
https://eel.is/c++draft/expr.const#4.3
https://github.com/llvm/llvm-project/pull/73376
More information about the cfe-commits
mailing list