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

Johannes Schaub (litb) schaub.johannes at googlemail.com
Sat Jan 29 22:01:51 PST 2011


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!
> 

I think that behavior is undefined for any program that uses a literal 
suffix without a leading underscore, because those names are reserved for 
use by a further Standard. 

Therefor, I think clang's lexer could just prefer lexing "0x123p4" as a 
floating point literal and can issue a warning about declarations of names 
such as 'operator "" p' ("warning: literal operator will never be used 
implicitly" or some such). 

I think independently of that, emitting a warning would be a good idea for 
'operator "" L(unsigned long long)' too. Since unless I'm mistaken, that 
operator cannot be called implicitly either ("12L" isn't a user defined 
literal). 





More information about the cfe-dev mailing list