https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128425
contact.yiran.wang at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |contact.yiran.wang at gmail
dot co
| |m
--- Comment #1 from contact.yiran.wang at gmail dot com ---
The reflections returned by reflect_constant_array and reflect_constant_string
are also treated as variables, not as
objects. With trunk 20261124 (x86_64-linux-gnu), g++ -std=c++26 -freflection
-fsyntax-only:
#include <meta>
#include <string_view>
using namespace std::meta;
using T = int[];
struct S { int i; };
constexpr info a = reflect_constant_array(T{0});
constexpr info s = reflect_constant_string(std::string_view("abc"));
constexpr info c = reflect_constant(S{1});
static_assert(is_object(a)); // fails
static_assert(!is_variable(a)); // fails
static_assert(!has_parent(a)); // fails: parent_of(a) == ^^::
static_assert(is_object(s)); // fails
static_assert(!is_variable(s)); // fails
static_assert(!has_parent(s)); // fails
static_assert(is_object(c) && !is_variable(c) && !has_parent(c) &&
!has_identifier(c)); // OK
[meta.define.static] says that both functions return ^^P where P is a template
parameter object, so I would expect
the same answers as for reflect_constant of a class type.
It looks like one cause with the has_identifier result:
eval_reflect_constant_string and eval_reflect_constant_array
return get_reflection_raw (loc, decl) with the default kind for the VAR_DECL
from get_template_parm_object, and
eval_is_object only checks kind == REFLECT_OBJECT.
(Prepared with the help of an AI coding assistant (Claude); the test was run on
my machine.)