This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: warning patch for gcc/config files
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>, rth at cygnus dot com
- Subject: Re: warning patch for gcc/config files
- From: Richard Henderson <rth at cygnus dot com>
- Date: Fri, 23 Oct 1998 11:58:55 -0700
- Cc: egcs-patches at cygnus dot com
- References: <199810231822.OAA29977@caip.rutgers.edu>
- Reply-To: Richard Henderson <rth at cygnus dot com>
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~