In C, a conditional expression is not an lvalue, nor is its result.
| Type of one operand | Type of other operand | Type of result |
|---|---|---|
| Arithmetic | Arithmetic | Arithmetic type after usual arithmetic conversions |
| Structure or union type | Compatible structure or union type | Structure or union type with all the qualifiers on both operands |
| void | void | void |
| Pointer to compatible type | Pointer to compatible type | Pointer to type with all the qualifiers specified for the type |
| Pointer to type | NULL pointer (the constant 0) | Pointer to type |
| Pointer to object or incomplete type | Pointer to void | Pointer to void with all the qualifiers specified for the type |
In
GNU C, a conditional expression is a valid lvalue, provided that its
type is not void and both of its branches are valid
lvalues. The following conditional expression (a ? b : c) is
legal under GNU C: (a ? b : c) = 5 /* Under GNU C, equivalent to (a ? b = 5 : (c = 5)) */This extension is available when compiling in one of the extended language levels.