On 2008-02-06 21:17:53 +0100, Manuel López-Ibáñez wrote:
> On 06/02/2008, Vincent Lefevre <[EMAIL PROTECTED]> wrote:
> > The problem is the cast (suggested by Dave Korn), not the enum itself:
> > (int) 0x80001000
> >
> 
> What is the problem with the cast? Do you want a warning for the
> conversion that you asked for with the cast? We want about implicit
> conversions with -Wconversion but if you use a cast, we understand
> that you really mean to perform the conversion.

The problem is that the conversion here is implementation-defined,
and may raise a signal on some platforms; so, this is a non-portable
construct. I think that a warning should be issued because the value
is out-of-range. This would allow to detect problems that can arise
on some platforms, e.g. with code like:

#include <stdio.h>
#include <limits.h>

int main (void)
{
  printf ("%ld\n", (long) UINT_MAX);
  return 0;
}

On platforms where int and long have the same size (so that UINT_MAX
isn't representable in a long), a warning would be useful.

-- 
Vincent Lefèvre <[EMAIL PROTECTED]> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)

Reply via email to