This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: type mismatch in conditional expression...used to compile fine


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]