https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107815

--- Comment #4 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot 
Uni-Bielefeld.DE> ---
> --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
>> The line before the assertion failure is
>> 
>> 1.18973e+4932 1e+4932
>> /vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/20_util/to_chars/
>> float128_c++23.cc:66: void test(std::chars_format): Assertion 'ec2 ==
>> std::errc() && ptr2 - str2 == ptr1 - str1' failed.
>> 
>> i.e. LDBL_MAX.

One thing that is also weird is that gdb prints u as infinity here, but
that may well a gdb quirk.

(gdb) p/x u
$2 = 0x7ffeffffffffffffffffffffffffffff
(gdb) ptype u
type = _Float128

> This is weird.  If line 66 is reached, fmt must be std::chars_format::fixed
> and in that case ptr1 - str1 should be 4933 and str1 should be that many chars
> long string starting with
> 11897314953572317650857593266280070161964690526416940455296988842121635797553123923249740128484620735259020335647491268597552654335738044626726987519452614908534619587250212628458657994054044935746815
> If you get just 1e+4932 when asked for fixed format, something is just wrong,
> that is scientific or general format.

I found that sprintf_ld returns 7 for the value above.  It is called
with

Thread 2 hit Breakpoint 1, 0xff0efd9c in std::(anonymous
namespace)::sprintf_ld<long double> (value=infinity, format_string=0xfefcec38
"%.0Lf", length=4934, buffer=0xffbfe8c8 "\177\376", '\377' <repeats 14 times>)
at
/vol/gcc/src/hg/master/local/libstdc++-v3/src/c++17/floating_to_chars.cc:1052

and a simple

        sprintf (buf, "%.0Lf", (long double) LDBL_MAX);

indeed returns 7.

Reply via email to