[Bug c++/123661] [reflection] Cannot return a pointer member from a splice expression
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 11 07:21:07 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123661
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:a1e81f838a38e37d7a659406f8fea1dba8f26406
commit r16-7445-ga1e81f838a38e37d7a659406f8fea1dba8f26406
Author: Boris Staletic <boris.staletic@protonmail.com>
Date: Wed Feb 11 16:20:49 2026 +0900
c++/reflection: Allow address-splicing of non-static members [PR123660,
PR123661]
In case of expressions like `&[:expr:]` where `expr` depends on a
template parameter, and the splice expression represents a `FIELD_DECL` or
a non-static member `FUNCTION_DECL`, that's exactly what we'd pass on.
However, `build_x_unary_op()` for these expressions is expecting an
`OFFSET_REF`. `OFFSET_REF` is also what gets passed to
`build_x_unary_op()` when templates are not involved.
There's also a difference between the template argument being a type and
using `members_of()` to get to the reflections of members (in which case
evaluating the `SPLICE_EXPR` returns a `FUNCTION_DECL` - `splice10.C`
test) and passing `^^T::member` as the template argument (in which case
evaluating the `SPLICE_EXPR` returns a `BASELINK` - `splice11.C`).
Signed-off-by: Boris Staletic <boris.staletic@protonmail.com>
PR c++/123660
PR c++/123661
gcc/cp/ChangeLog:
* pt.cc (tsubst_splice_expr): Handle pointers to non-static members
from splice expressions
gcc/testsuite/ChangeLog:
* g++.dg/reflect/splice10.C: New test.
* g++.dg/reflect/splice11.C: New test.
More information about the Gcc-bugs
mailing list