[cfe-commits] Patch for evaluating FP constant expressions

Chris Lattner clattner at apple.com
Thu Nov 29 15:07:04 PST 2007


On Nov 29, 2007, at 2:37 PM, Neil Booth wrote:

> Chris Lattner wrote:-
>
>>> I needed this to support negation of FP literals, which is pretty
>>> unambiguous. It looks like GCC evaluates more complex constant
>>> expressions too, so I put in support for some of that (though
>>> rounding mode is an issue). All of this is modeled on the work for
>>> integer expressions and uses APFloat.
>>
>> Very interesting, I didn't realize that this was non-conforming:
>>
>> double x = -1.0;
>
> I don't understand?  This is quite OK of course, and required to be
> accepted.
>
> I see a lot of confusion about initializers.

You're much more of a standard's guru than I am, but my reading of  
6.6p7 would imply that this is an arithmetic constant expression, and  
p8 says "An arithmetic constant expression shall have arithmetic type  
and shall only have
operands that are integer constants, floating constants, enumeration  
constants, character
constants, and sizeof expressions".  That makes it sound like "- 1.0"  
is not a valid c-e, no?

-Chris



More information about the cfe-commits mailing list