https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125886

--- Comment #2 from Vladislav Semykin <vladislav.semykin at gmail dot com> ---
I missed the polymorphic case. As Marek Polacek noted in the review,
when the operand is a glvalue of polymorphic class type, it must be
evaluated per [expr.typeid]/5. My current patch sets
cp_unevaluated_operand unconditionally, which is incorrect.

I'll look into parsing the operand twice: first in an unevaluated
context to determine the type, then re-parsing in an evaluated context
if the type turns out to be a polymorphic glvalue.

Also, it would be a new test case:

// Polymorphic glvalue: operand is evaluated per [expr.typeid]/5,
// so std::declval is ill-formed here.
class B { virtual ~B(); };
void bar() { char const *a = typeid(std::declval<B>()).name(); }

Reply via email to