On 6/26/26 4:45 PM, Vladislav Semykin wrote:
> Does this also fix PR116385 and PR68604?
Yes, both, confirmed with the reproducers from those PRs:
- for PR116385 all four cases (lambda, local class, and the two
default-argument uses) now compile;
- for PR68604, typeid(A::i) compiles in C++11+.
One thing I caught while testing:
typeid(A::i) must remain ill-formed in C++98 (DR613 only applies from C++11),
Since it's a DR, we chose to apply it to C++98 mode as well; the
handling in finish_non_static_data_member doesn't check cxx_dialect. It
would be odd to restrict it only in this corner case.
2. Polymorphic glvalue inside a lambda: should be odr-used and captured,
but currently isn't.
I think this should also be handled in this patch. I'm surprised it
doesn't just work.
+ /* Reuse the same predicate as build_typeid (rtti.cc) so
+ there is a single source of truth for the [expr.typeid]/4
+ condition. */
+ int nonnull = 0;
+ tree t = TREE_TYPE (expression);
+ need_eval = (CLASS_TYPE_P (t)
+ && TYPE_POLYMORPHIC_P (t)
+ && !resolves_to_fixed_type_p (expression, &nonnull)
+ && !nonnull
+ /* Only glvalues are evaluated. */
+ /* prvalues are unevaluated even for
+ polymorphic types. */
+ && glvalue_p (expression));
This predicate should be factored out rather than copied.
Jason