[Bug c++/85889] lambda expression can capture structured bindings
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu May 9 17:03:48 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85889
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:46bafd9a6b9b776142e0b1424a6ac02e3a2fd300
commit r15-348-g46bafd9a6b9b776142e0b1424a6ac02e3a2fd300
Author: Marek Polacek <polacek@redhat.com>
Date: Fri Mar 1 17:13:02 2024 -0500
c++: lambda capturing structured bindings [PR85889]
<https://wg21.link/p1381r1> clarifies that it's OK to capture structured
bindings.
[expr.prim.lambda.capture]/4 says "The identifier in a simple-capture shall
denote a local entity" and [basic.pre]/3: "An entity is a [...] structured
binding".
It doesn't appear that this was made a DR, so, strictly speaking, we
should have a -Wc++20-extensions warning, like clang++.
PR c++/85889
gcc/cp/ChangeLog:
* lambda.cc (add_capture): Add a pedwarn for capturing structured
bindings.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/decomp3.C: Use -Wno-c++20-extensions.
* g++.dg/cpp1z/decomp60.C: New test.
More information about the Gcc-bugs
mailing list