[Bug c++/124770] [reflection] odr-used inline variable of consteval-only type incorrectly not defined
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu May 7 22:11:58 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124770
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:3058891d5c6f114d86a9a8c87fd52f202decff53
commit r16-8880-g3058891d5c6f114d86a9a8c87fd52f202decff53
Author: Marek Polacek <polacek@redhat.com>
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 <jason@redhat.com>
(cherry picked from commit 6d035aa99c3d1197167e085302d8ce015b950b35)
More information about the Gcc-bugs
mailing list