[Bug c++/123667] [14 Regression] ICE in finish_decltype_type when using decltype on a structured binding inside a generic lambda since r14-9258
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Mar 15 06:06:59 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123667
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:36849881f44079e013c3f1f46d1e0fdc111553fc
commit r14-12396-g36849881f44079e013c3f1f46d1e0fdc111553fc
Author: Jakub Jelinek <jakub@redhat.com>
Date: Sat Jan 24 10:36:45 2026 +0100
c++: Fix ICE on decltype on non-local structured binding inside of a
template [PR123667]
The following testcases ICE when decltype (x) appears in a template
where x is a tuple based structured binding from outside of that template
(one testcase shows the sb in a function and template is a lambda within
that function, the other shows namespace scope sb referenced from a
template).
What I wrote in the comment there is true only for structured bindings
within the current template function, in that case that structured binding
indeed has to have DECL_VALUE_EXPR and lookup_decomp_type might return
NULL or might not and depending on that we should choose if it is
a tuple based structured binding and return its type or if we should
return unlowered type of expr.
But if decltype in a template refers to a structured binding elsewhere,
it could have been finalized already and determined to be tuple based
structured binding, so DECL_HAVE_VALUE_EXPR_P can be false in that case.
In that case, if ptds.saved would be false, we'd just always
return lookup_decomp_type. So, for this case the patch allows
that case in the assert and asserts lookup_decomp_type returned non-NULL.
2026-01-24 Jakub Jelinek <jakub@redhat.com>
PR c++/123667
* semantics.cc (finish_decltype_type): Allow a structured binding
for ptds.saved to have DECL_HAS_VALUE_EXPR_P cleared, if it is
not within current_function_decl, but in that case assert that
lookup_decomp_type succeeded.
* g++.dg/cpp1z/decomp66.C: New test.
* g++.dg/cpp1z/decomp67.C: New test.
(cherry picked from commit 34a47a8b14e2a74d35a65ccc2bd2a166106b9b96)
More information about the Gcc-bugs
mailing list