Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/16?
-- >8 --
We crash here in outer_var_p on:
/* These should have been stripped or otherwise handled by the caller. */
gcc_checking_assert (!REFERENCE_REF_P (decl));
because we never stripped the INDIRECT_REF in get_reflection. I don't
think stripping it only for the outer_automatic_var_p call would be
right so I'm doing it at the top of the function.
PR c++/125759
gcc/cp/ChangeLog:
* reflect.cc (get_reflection): Do STRIP_REFERENCE_REF.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/expr17.C: New test.
---
gcc/cp/reflect.cc | 1 +
gcc/testsuite/g++.dg/reflect/expr17.C | 7 +++++++
2 files changed, 8 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/reflect/expr17.C
diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc
index 673b79d0bde..23a309b96ab 100644
--- a/gcc/cp/reflect.cc
+++ b/gcc/cp/reflect.cc
@@ -135,6 +135,7 @@ tree
get_reflection (location_t loc, tree t, reflect_kind kind/*=REFLECT_UNDEF*/)
{
STRIP_ANY_LOCATION_WRAPPER (t);
+ t = STRIP_REFERENCE_REF (t);
/* Constant template parameters and pack-index-expressions cannot
appear as operands of the reflection operator. */
diff --git a/gcc/testsuite/g++.dg/reflect/expr17.C
b/gcc/testsuite/g++.dg/reflect/expr17.C
new file mode 100644
index 00000000000..6142272291d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/reflect/expr17.C
@@ -0,0 +1,7 @@
+// PR c++/125759
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+consteval auto foo(auto&&... xs) { return (^^xs, ...); }
+constexpr auto r1 = foo (0);
+constexpr auto r2 = foo (0, 1u);
base-commit: 4ef64ad1aa9bbbe9471610e2de6ef0c8afed8b1f
--
2.54.0