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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <[email protected]>:

https://gcc.gnu.org/g:6d035aa99c3d1197167e085302d8ce015b950b35

commit r17-392-g6d035aa99c3d1197167e085302d8ce015b950b35
Author: Marek Polacek <[email protected]>
Date:   Tue Apr 21 15:54:33 2026 -0400

    c++/reflection: odr-used inline var of consteval-only type [PR124770]

    wrapup_namespace_globals gives errors for code like

      extern inline int i;
      int &r = i; // odr-used inline variable is not defined

    but because we mark consteval-only vars DECL_EXTERNAL, we also wrongly
    emit the error for:

      inline constexpr info value{};
      static_assert(value == info{});

    where value clearly is defined.  This patch strenghtens the check to
    also check !DECL_INITIAL.  We can't only check DECL_THIS_EXTERN because

      extern constexpr inline info v2{};

    is OK.

            PR c++/124770

    gcc/cp/ChangeLog:

            * decl.cc (wrapup_namespace_globals): Give the odr-used
            inline variable error only when !DECL_INITIAL.

    gcc/testsuite/ChangeLog:

            * g++.dg/reflect/init18.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to