type mismatch in conditional expression...used to compile fine
Fergus Henderson
fjh@cs.mu.oz.au
Thu Jan 4 19:21:00 GMT 2001
On 04-Jan-2001, Robby Dermody (Nova) <nova@pimpsmack.org> wrote:
> The main question I have is: Is the conditional operator supposted to
> require that the last two operends be of the same type
Not quite. Here's the exact rule from the ISO C standard:
| 6.5.15 Conditional operator
...
| [#3] One of the following shall hold for the second and
| third operands:
|
| -- both operands have arithmetic type;
|
| -- both operands have the same structure or union type;
|
| -- both operands have void type;
|
| -- both operands are pointers to qualified or unqualified
| versions of compatible types;
|
| -- one operand is a pointer and the other is a null
| pointer constant; or
|
| -- one operand is a pointer to an object or incomplete
| type and the other is a pointer to a qualified or
| unqualified version of void.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: < http://www.cs.mu.oz.au/~fjh > | -- the last words of T. S. Garp.
More information about the Gcc
mailing list