I believe the extract actually covers that:
If e
satisfies the constraints of a core constant expression, but evaluation of e would evaluate an operation that has undefined behaviour as specified in [library]
through [thread]
of this document, it is unspecified whether e
is a core constant expression.
There is actually no undefined behaviour in the expression ""[0]?""[1]:'\0'
because the only problematic bit ""[1]
is never actually executed. In fact, the entire expression can simply be optimised to '\0'
without adverse effects.
The reason it's not executed comes from the standard itself (e.g., C++11 5.16 Conditional operator [expr.cond] /1
:
Conditional expressions group right-to-left. The first expression is contextually converted to bool
(Clause 4). It is evaluated and if it is true, the result of the conditional expression is the value of the second expression,
otherwise that of the third expression. Only one of the second and third expressions is evaluated.
Since ""[0]
will always evaluate to false in the boolean context, the second sub-expression is never executed. It's really no conceptually different from the expression:
false ? (1/0) : 42
in that you'll never actually have to worry about the possibility of divide-by-zero.