-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
num_get::do_get incorrect digit grouping check #29078
Comments
assigned to @mclow |
Reduced test case |
If you've said "this is a facet that does grouping", then it's hard to argue that "no grouping" is consistent with that facet. On the other hand, the original example would be nice to support. |
Fixed in revision 362508. |
Marshall, your libcxx commit changes a line in src/locale.cpp from
to
which might have been meant to be |
thanks. Commit 363557 |
Note this is 2dda1ff. |
Extended Description
For a locale which specifies digit grouping, num_get::do_get will enforce
that the number read in contains the grouping character at the correct
locations. It does this even if the number read in didn't have any grouping
characters present.
This is shown best with a code example:
#include
#include
int main()
{
std::locale::global(std::locale("en_US.UTF-8"));
std::istringstream iss("1024");
int a = 0;
iss >> a;
std::cout << a << ", " << iss.fail() << std::endl;
}
With libc++ this prints:
1024, 1
With libstdc++ this prints:
1024, 0
http://coliru.stacked-crooked.com/a/9283df64c2bd5142
The standard says:
http://eel.is/c++draft/facet.num.get.virtuals#4
Whilst the standard could be clearer, it seems one can take it to mean that as
there are no discarded characters, there is nothing to examine for consistency.
This is the approach that libstdc++ takes, as well as boost's lexical_cast:
https://svn.boost.org/trac/boost/ticket/5585
I think it's reasonable that libc++ changes its implementation to match.
The text was updated successfully, but these errors were encountered: