https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126680
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-16 branch has been updated by Marek Polacek <[email protected]>: https://gcc.gnu.org/g:e36bd73d7030b3efb182821f06c48c5258809766 commit r16-9812-ge36bd73d7030b3efb182821f06c48c5258809766 Author: Marek Polacek <[email protected]> Date: Mon Oct 12 17:04:24 2026 -0400 c++/reflection: ICE with reflection and sb packs [PR126680] We mark consteval-only vars DECL_EXTERNAL, which confused the code in set_decl_context_in_fn: if (TREE_CODE (decl) == FUNCTION_DECL || (VAR_P (decl) && DECL_EXTERNAL (decl))) /* Make sure local externs are marked as such. OMP UDRs really are nested functions. */ gcc_checking_assert (DECL_LOCAL_DECL_P (decl) /*...*/ ); for code with: static constexpr auto [...a] = std::array { ^^int }; where there is no local extern. This reminded me of r17-392, and I think here we can use DECL_THIS_EXTERN. I think we shouldn't lose any relevant coverage because of this change. We set DECL_THIS_EXTERN in grokvardecl: DECL_THIS_EXTERN (decl) = 1; DECL_EXTERNAL (decl) = !initialized; and in grokdeclarator, which sets DECL_THIS_EXTERN only after grokvardecl has been called. A local extern with an initializer is rejected in grokdeclarator. So a block-scope VAR_DECL with DECL_THIS_EXTERN always has DECL_EXTERNAL set. PR c++/126680 gcc/cp/ChangeLog: * name-lookup.cc (set_decl_context_in_fn): Check DECL_THIS_EXTERN instead of DECL_EXTERNAL. gcc/testsuite/ChangeLog: * g++.dg/reflect/decomp1.C: New test. Reviewed-by: Jason Merrill <[email protected]> (cherry picked from commit eb5375341a4743fa565626a0d1ffc51f87dba577)
