This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Add validation to Stage 2 of num_get
Needs ReviewPublic

Authored by vangyzen on Nov 21 2016, 10:01 AM.

Details

Summary

LWG 2381 clarifies that Stage 2 of num_get should check that the
to-be-accumulated character would be valid as the next character
in the accumulated sequence. This change adds the check (for
floating-point numbers) and a unit test with the example proposed
by LWG 2381. If this is approved, I'll see if integers need a
similar change.

I believe this fixes PR#17782:

https://llvm.org/bugs/show_bug.cgi?id=17782

We also hit this in the real world on FreeBSD 10.3.

Event Timeline

vangyzen updated this revision to Diff 78735.Nov 21 2016, 10:01 AM
vangyzen retitled this revision from to Add validation to Stage 2 of num_get.
vangyzen updated this object.
vangyzen updated this object.Nov 21 2016, 10:12 AM
vangyzen updated this object.
vangyzen added inline comments.Nov 21 2016, 10:48 AM
include/locale
529

I suppose I could use "& 0x5F" to avoid the branches in these comparisons of __x.

vangyzen updated this object.Nov 22 2016, 9:56 AM

On Fedora 24, all std/localization test results are as expected.

On FreeBSD 11, all std/.../category.numeric tests pass, and there are no additional unexpected results under std/localization.

While I'm on that topic: Under std/localization, the number of unexpected failures on FreeBSD is almost the same as the expected failures on Fedora. Perhaps they are due to hard-coded expectations about locale data. A proposed fix for some of these is in D26979.

vangyzen retitled this revision from Add validation to Stage 2 of num_get to [libc++] Add validation to Stage 2 of num_get.Nov 28 2016, 9:16 AM
vangyzen added a reviewer: EricWF.
vangyzen updated this revision to Diff 79625.Nov 29 2016, 1:06 PM

Restore support for a sign character preceding a "nan"

I accidentally broke +nan and -nan. Add unit test cases for these,
and update my change to support them.