[Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
nishida_kenji at nintendo dot co.jp
gcc-bugzilla@gcc.gnu.org
Thu Apr 21 01:40:38 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105324
Bug ID: 105324
Summary: std::from_chars() assertion at
floating_from_chars.cc:78 when parsing 1.11111111....
Product: gcc
Version: 11.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nishida_kenji at nintendo dot co.jp
Target Milestone: ---
CODE:
--------
#include <memory>
#include <charconv>
#include <cstring>
#include <cstdio>
int main() {
#ifdef __GLIBCXX__
std::printf("GLIBCXX: %d\n",__GLIBCXX__);
#endif
std::unique_ptr<char[]> mem(new char[1024 * 128]);
std::memset(mem.get(), '1', 10000);
mem[1] = '.';
mem[511] = '\0';
double val;
std::from_chars(mem.get(), mem.get() + 511, val);
std::printf("511: %f\n", val);
std::memset(mem.get(), '1', 10000);
mem[1] = '.';
mem[512] = '\0';
std::from_chars(mem.get(), mem.get() + 512, val);
std::printf("512: %f\n", val);
return 0;
}
---
RESULT:
GLIBCXX: 20220127
511: 1.111111
../../../../../libstdc++-v3/src/c++17/floating_from_chars.cc:78: virtual void*
std::{anonymous}::buffer_resource::do_allocate(std::size_t, std::size_t):
Assertion 'alignment != 1' failed.
More information about the Gcc-bugs
mailing list