[cfe-commits] r42238 - /cfe/trunk/AST/Expr.cpp

Neil Booth neil at daikokuya.co.uk
Sat Sep 22 17:33:08 PDT 2007


Chris Lattner wrote:-

> Use the APFloat routines to evaluate FP immediates as 
> integer constant expressions.  The only questionable
> thing is that we now reject:
> 
> void foo() {
>   switch (1) {
>   case (int)1.0e10000:
>     ;
>   }
> }
> 
> with:
> 
> t.c:5:13: error: case label does not reduce to an integer constant
>   case (int)1.0e10000:
>        ~~~~~^~~~~~~~~
> 
> GCC accepts this, emitting the pedwarn:
> t.c:5: warning: floating constant exceeds range of 'double'

You could just set the integer value to the largest value.  Or is
something else the problem here?

FWIW I tend to think such code should always be a hard error; I
see little value in accepting such things :)

Neil.



More information about the cfe-commits mailing list