[cfe-commits] r44339 - in /cfe/trunk: Lex/LiteralSupport.cpp include/clang/Lex/LiteralSupport.h

Ted Kremenek kremenek at apple.com
Thu Nov 29 11:22:02 PST 2007


On Nov 27, 2007, at 5:14 AM, Neil Booth wrote:

> I realize you didn't write it but that local buffer overflow
> has to go :)

It's now gone.  :)

> If ThisTokEnd points to a valid character that cannot continue
> the literal, then pass ThisTokBegin and be done with it - APFloat
> parses until the first character that is syntactically incorrect;
> it assumes the caller has verified the syntax.  In other words
> \0 is just one example of a suitable terminator; almost anything
> outside [0-9.eE+-pP] will do.

Unfortunately, it's not clear that what ThisTokEnd points to will have  
these kind of guarantees.  I would need to look more on what exactly  
APFloat considers a terminator.  Alternatively, providing an extent to  
convertFromString would make the interface more generic, allowing one  
to parse APFloats from any arbitrary buffer.

>> +#if 1
>> +  APFloat V (Format, APFloat::fcZero, false);
>> +
>> +  APFloat::opStatus status;
>> +  status = V.convertFromString(floatChars,APFloat::rmTowardZero);
>> +
>> +  if (isExact)
>> +    *isExact = status == APFloat::opOK;
>> +
>> +  return V;
>
> I think in general we should be rounding to nearest, not zero.

Fixed.  Thanks!



More information about the cfe-commits mailing list