-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!
Description
Describe the bug
_Stodx_v2 and _Stofx_v2 contains:
Lines 58 to 60 in b1fbbdc
| if (_Pten != 0) { | |
| _Val *= _CSTD pow(10.0, static_cast<double>(_Pten)); | |
| } |
Like almost all of our pre-charconv floating-point formatting, I believe that this is incorrect - dividing by a power of 10 isn't an exact operation.
I believe that this code path is only activated when the integral part of the significand is longer than 768 digits (which overflows without a negative exponent).
Command-line test case
D:\Temp>type long_num_get.cpp
#include <cassert>
#include <sstream>
#include <string>
using namespace std;
int main() {
istringstream iss{"1" + string(2000, '0') + "e-2000"};
double x;
assert(iss >> x);
assert(x == 1.0);
return 0;
}D:\Temp>cl /EHsc /W4 /WX long_num_get.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29812 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
long_num_get.cpp
Microsoft (R) Incremental Linker Version 14.28.29812.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:long_num_get.exe
long_num_get.obj
D:\Temp>.\long_num_get.exe
Assertion failed: iss >> x, file long_num_get.cpp, line 10
STL version
Microsoft Visual Studio Community 2019 Preview
版本 16.9.0 Preview 3.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!