Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
Qt Creator 1.3.1
-
None
-
Linux kunyang 2.6.33-ARCH #1 SMP PREEMPT Thu May 13 11:32:37 CEST 2010 x86_64 Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz GenuineIntel GNU/Linux
Description
The expression (1 ? 2,3 : 4) is valid (and evaluates to 3), but qt-creator's parser complains: "expected token `:' got `,'. Quoting from the footnote at the beginning of section "6.5 Expressions" in WG14/N1256 (ISO 9899:TC3):
The syntax specifies the precedence of operators in the evaluation of an expression, which is the same
as the order of the major subclauses of this subclause, highest precedence first. Thus, for example, the
expressions allowed as the operands of the binary + operator (6.5.6) are those expressions defined in
6.5.1 through 6.5.6. The exceptions are cast expressions (6.5.4) as operands of unary operators
(6.5.3), and an operand contained between any of the following pairs of operators: grouping
parentheses () (6.5.1), subscripting brackets [] (6.5.2.1), function-call parentheses () (6.5.2.2), and
the conditional operator ?: (6.5.15).
Since there is no ambiguity in the second argument of the ternary operator, this footnote is not necessary to make the expression above valid, but the footnote makes it clear that the comma operator may occur within the conditional operator.