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

--- Comment #3 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
This raises a question of whether the interpretation of the type of the
controlling expression "as if it had undergone an lvalue conversion" (per the
resolution of issue 0481) also engages the (translation-time) undefined
behavior (constraint violation in C2Y after the adoption of N3481 in Graz) for
such a conversion of an lvalue with incomplete type.

I previously (reflector message 28292, 30 Jan 2025) noted a similar question
with unselected generic associations.

I would argue that the particular case here is invalid independent of those
questions, because of the conditional expression: the lvalues in question are
operands of ?:, which means they get converted to rvalues, and the fact that
the conditional expression is not evaluated is irrelevant, because the lvalues
are evaluated *relative to that expression*, much as if the conditional
expression were contained inside if (0) - the controlling expression is subject
to all normal rules on validity of expressions even though it's not evaluated
at execution time. (The "Discarded" series of papers would say the controlling
expression is "discarded relative to the generic selection". This avoids issues
with "not evaluated" being an execution-time concept, so not suitable for
translation-time undefined behavior or constraints.)

Reply via email to