This is the mail archive of the gcc-patches@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: warning patch for gcc/config files


On Fri, Oct 23, 1998 at 02:22:11PM -0400, Kaveh R. Ghazi wrote:
>  > From: Richard Henderson <rth@cygnus.com>
>  > 
>  > The Alpha bits are fine.  I do have one question as to why
>  > 
>  > -#define Pmode (TARGET_PTR64 ? DImode : SImode)
>  > +#define Pmode ((enum machine_mode)(TARGET_PTR64 ? DImode : SImode))
>  > 
>  > is necessary.  The two arms of the ?: have the same type, which is
>  > passed on to the result.
>  > r~
> 
> 	Try compiling the following:
> 
>  > enum machine_mode { zero, one, two };
>  >  
>  > int main()
>  > {
>  >   int i = 0;
>  >   enum machine_mode mode = zero;
>  >  
>  >   if (mode == (i ? one : two))
>  >     return i;
>  >  
>  >   return i;
>  > }
> 
> 	When I do it, I get a warning:
> 
>  > % gcc -W -Wall bar.c
>  > bar.c: In function `main':
>  > bar.c:8: warning: comparison between signed and unsigned
> 
> 
> 	The cast makes it happy again.

I'd like you to delay this change, as I believe that it points out
a bug in gcc.

To whit: the same promotion was not performed on mode, one, and two.

There is a secondary quirk that is less clear.  The standard says
that the second and third operands are converted by the standard
rules to a common type, and that the result has that type.  Thus
while it is not clear that (i ? one : two) having type int is wrong,
it doesn't seem right either.

Either that, or the warning test itself is way out in left field.


r~


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