[PATCH] Fix 'leading zeros' caveat of StringRef::compare_numeric()
Sanne Wouda
snnw at gruttepier.net
Fri Apr 3 02:24:46 PDT 2015
Ah, I see. Then it would make sense to detect the radix from a
number's prefix (0 for octal, 0x for hex, anything else for decimal)
and use strtol() to convert to a long. That should simplify this code
significantly (also compared to the previous version). I'll whip up a
patch in a week or so.
On Mon, Mar 30, 2015 at 5:19 PM, Chandler Carruth <chandlerc at google.com> wrote:
> Correct.
>
> On Mon, Mar 30, 2015 at 10:49 AM Marshall Clow <mclow.lists at gmail.com>
> wrote:
>>
>> On Mon, Mar 30, 2015 at 6:26 AM, Sanne Wouda <snnw at gruttepier.net> wrote:
>>>
>>>
>>> Regarding octal numbers: I believe behaviour is unchanged. Comparison
>>> between two octal numbers (with or without leading zeroes) should work
>>> as expected. Exactly which behaviour are you worried about?
>>>
>>
>> I suspect that Chandler is concerned about these two case giving different
>> answers:
>>
>> if ( 010 < 9 ) printf ("true"); // will print.
>> if ( StringRef("010").compare_numeric("9") < 0 ) printf ("true"); //
>> will NOT print.
>>
>> -- Marshall
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list