[cfe-dev] hexfloats in c++0x

Sean Hunt scshunt at csclub.uwaterloo.ca
Thu Jan 27 15:33:45 PST 2011


On 11-01-27 02:48 PM, Douglas Gregor wrote:
>
> On Jan 27, 2011, at 10:50 AM, Howard Hinnant wrote:
>
>> Can we turn on support for hexfloats in -std=c++0x?  It is already turned on in c++03 mode.
>>
>> get_double.pass.cpp:108:14: error: invalid suffix 'p' on integer constant
>>         assert(v == 0x125p-1);
>>         ^
>
> They're disabled in C++0x mode because they conflict with user-defined literals. We might be able to jump through some hoops to see if there's a literal operator named "p" or "P" in scope, but... yuck.
>
> Suggestions welcome!
>
> 	- Doug

What's more, there should be a warning in C++03 mode to the effect that 
they are incompatible with C++0x. It is not reasonably implementable in 
C++0x.

Consider 0x123p4. In C99 the meaning is clear; in C++0x this clearly 
means a call to operator "" p4. It seems really ugly to enable both

Now, it's worth nothing that every literal name starting with a 
non-underscore is "reserved for future standardization", which I 
interpret to mean "the program is well-formed but might not be in the 
future". It would probably be reasonable to implement a -f flag to make 
hex exponents take precedence over user-defined literals, but I do not 
think we can do that by default.

Sean



More information about the cfe-dev mailing list