This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: type mismatch in conditional expression...used to compile fine
- To: "Robby Dermody (Nova)" <nova at pimpsmack dot org>
- Subject: Re: type mismatch in conditional expression...used to compile fine
- From: Fergus Henderson <fjh at cs dot mu dot oz dot au>
- Date: Fri, 5 Jan 2001 14:20:57 +1100
- Cc: gcc at gcc dot gnu dot org
- References: <3A54E739.A9F2C7B4@pimpsmack.org>
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.