Name n3753, alx-0030r1 - The Elvis operator ?: Principles - Codify existing practice to address evident deficiencies. Category Avoid multiple-evaluation isses. Author Alejandro Colomar History r0 (2025-06-24): - Initial draft. r1 (2025-12-01; n3753): - Use (opt) syntax. Description The expression 'x ? x : y' isn't safe within macros: it evaluates 'x' twice. Some implementations allow omitting the second operand of this operator, which results in the same semantics, except that the first operand is not evaluated twice. Prior art GNU C. Proposed wording Based on N3550. 6.5.16 Conditional operator @@ Syntax, p1 conditional-expression: logical-OR-expression - logical-OR-expression ? expression : conditional-expression + logical-OR-expression ? expression(opt) : conditional-expression @@ Semantics, p5 The first operand is evaluated; there is a sequence point between its evaluation and the evaluation of the second or third operand -(whichever is evaluated). +(whichever is evaluated, +if at all). +If the second operand is specified, -The second operand is evaluated +the second operand is evaluated only if the first compares unequal to 0; the third operand is evaluated only if the first compares equal to 0; the result is the value of the second or third operand (whichever is evaluated), converted to the type described subsequently in this subclause. +If the second operand is not specified, +the expression behaves +as if the first operand was also used as the second operand, +except that it's not evaluated twice.