-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
Labels
libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.localeissues related to localizationissues related to localization
Description
When basefield == 0, __stage2_int_loop in num.h does not distinguish 'x'/'X' from digit characters (0–9, a–f, A–F). As a result, reading from "10xFFx01" (with basefield == 0) consumes the whole input.
Testcase:
#include <iostream>
#include <iomanip>
#include <sstream>
int main()
{
std::istringstream is("10xFFx0.1=FF");
int x;
is >> std::setbase(0);
is >> x;
bool failbit = is.fail();
if (failbit) is.clear();
auto next_pos = is.tellg();
std::cout << "value: " << x << '\n'; // expected: 10, actual: 0
std::cout << "fail: " << failbit << '\n'; // expected: 0, actual: 1
std::cout << "next: " << next_pos << '\n'; // expected: 2 (1st 'x'), actual: 7 ('.')
}It looks like PR #121795 fixes this issue.
Metadata
Metadata
Assignees
Labels
libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.localeissues related to localizationissues related to localization