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]
Other format: [Raw text]

Re: [4.3] wcoercion (3): conversion_warnings for C / C++


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.


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