This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [4.3] wcoercion (3): conversion_warnings for C / C++
- From: "Manuel López-Ibáñez" <lopezibanez at gmail dot com>
- To: "Rask Ingemann Lambertsen" <rask at sygehus dot dk>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, "Joseph Myers" <jsm at polyomino dot org dot uk>
- Date: Mon, 27 Aug 2007 11:37:36 +0100
- Subject: Re: [4.3] wcoercion (3): conversion_warnings for C / C++
- References: <6c33472e0611050636q40256ddalcd215f12bfc4ca58@mail.gmail.com> <20070826180258.GD25795@sygehus.dk>
On 26/08/07, Rask Ingemann Lambertsen <rask@sygehus.dk> wrote:
> On Sun, Nov 05, 2006 at 02:36:04PM +0000, Manuel López-Ibáñez wrote:
> >
>
> Why is this
>
> > + ffloat (INT_MAX); /* { dg-warning "conversion" } */
> > + vfloat = INT_MAX; /* { dg-warning "conversion" } */
>
> supposed to give a warning while this
>
> > + ffloat (INT_MIN);
> > + vfloat = INT_MIN;
>
> is not?
>
I guess because a float cannot hold INT_MAX (if you do float f =
INT_MAX; int d = f; you don't get INT_MAX in d), while it can hold an
INT_MIN.
> Anyway, what do you suggest for targets where a float can hold INT_MAX?
> Would it be a problem to use LONG_INT_MAX instead?
I guess not. However, I guess that you could modify the test so it
only executes on targets where it makes sense (using modifiers to
dg-warning or just using some #ifdef magic).
#ifdef INT16
ffloat (LONG_INT_MAX); /* { dg-warning "conversion" } */
vfloat = LONG_INT_MAX; /* { dg-warning "conversion" } */
ffloat (LONG_INT_MIN);
vfloat = LONG_INT_MIN;
#else
ffloat (INT_MAX); /* { dg-warning "conversion" } */
vfloat = INT_MAX; /* { dg-warning "conversion" } */
ffloat (INT_MIN);
vfloat = INT_MIN;
#endif
I don't think it is big deal either way.
Cheers,
Manuel.