[Bug c++/124770] [reflection] odr-used inline variable of consteval-only type incorrectly not defined

2026-05-07 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124770

Marek Polacek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #6 from Marek Polacek  ---
Fixed, thanks for reporting.

[Bug c++/124770] [reflection] odr-used inline variable of consteval-only type incorrectly not defined

2026-05-07 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124770

--- Comment #5 from GCC Commits  ---
The releases/gcc-16 branch has been updated by Marek Polacek
:

https://gcc.gnu.org/g:3058891d5c6f114d86a9a8c87fd52f202decff53

commit r16-8880-g3058891d5c6f114d86a9a8c87fd52f202decff53
Author: Marek Polacek 
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 
(cherry picked from commit 6d035aa99c3d1197167e085302d8ce015b950b35)

[Bug c++/124770] [reflection] odr-used inline variable of consteval-only type incorrectly not defined

2026-05-07 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124770

--- Comment #4 from GCC Commits  ---
The trunk branch has been updated by Marek Polacek :

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

commit r17-392-g6d035aa99c3d1197167e085302d8ce015b950b35
Author: Marek Polacek 
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 

[Bug c++/124770] [reflection] odr-used inline variable of consteval-only type incorrectly not defined

2026-04-17 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124770

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

[Bug c++/124770] [reflection] odr-used inline variable of consteval-only type incorrectly not defined

2026-04-16 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124770

--- Comment #3 from Marek Polacek  ---
Probably the fix is just to check !consteval_only_p (decl).

[Bug c++/124770] [reflection] odr-used inline variable of consteval-only type incorrectly not defined

2026-04-16 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124770

Marek Polacek  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2026-04-16

--- Comment #2 from Marek Polacek  ---
We give the error in wrapup_namespace_globals because we mark consteval-only
vars DECL_EXTERNAL.

[Bug c++/124770] [reflection] odr-used inline variable of consteval-only type incorrectly not defined

2026-04-06 Thread daniel.kruegler at googlemail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124770

--- Comment #1 from Daniel Krügler  ---
Reduced:

--
#include 

inline constexpr std::meta::info value{};

static_assert(value == std::meta::info{});
--

or if you prefer without header :

--
using T = decltype(^^::);

inline constexpr T value{};

static_assert(value == T{});
--