https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126137

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |jakub at gcc dot gnu.org
   Last reconfirmed|                            |2026-07-08

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem is that
make_rtl_for_nonlocal_decl
does:
8811      if (consteval_only_p (decl))
8812        {
8813          /* Disable assemble_variable.  */
8814          DECL_EXTERNAL (decl) = true;
8815          /* Undo make_decl_one_only.  */
8816          if (DECL_COMDAT_GROUP (decl))
8817            {
8818              symtab_node *node = symtab_node::get (decl);
8819              node->set_comdat_group (NULL);
8820              node->dissolve_same_comdat_group_list ();
8821            }
and later on cp_finish_decomp is called, copies the DECL_EXTERNAL flag to the
VAR_DECL created for each pack element:
11010                     TREE_VEC_ELT (packv, j + 2) = t = copy_node
(v[pack]);
11011                     set_sb_pack_name (t, j);
and
11214         if (!processing_template_decl)
11215           for (unsigned int i = 0; i < TREE_VEC_LENGTH (packv) - 2U; ++i)
11216             pushdecl (TREE_VEC_ELT (packv, 2 + i));
and crashes during the pushdecl because it asserts that
3671      if (TREE_CODE (decl) == FUNCTION_DECL
3672          || (VAR_P (decl) && DECL_EXTERNAL (decl)))
3673        /* Make sure local externs are marked as such.  OMP UDRs really
3674           are nested functions.  */
3675        gcc_checking_assert (DECL_LOCAL_DECL_P (decl)
3676                             && (DECL_NAMESPACE_SCOPE_P (decl)
3677                                 || (TREE_CODE (decl) == FUNCTION_DECL
3678                                     && DECL_OMP_DECLARE_REDUCTION_P
(decl))));
Note, in this case it isn't a real extern, just a consteval only typed
variable.

Unsure if this is worth addressing before consteval-only types are killed and
replaced with consteval-only values (with https://wg21.link/P4101R1 ).

Reply via email to