[Bug libstdc++/111747] Problem with large float list initialization

2023-10-10 Thread oplata.kes1 at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111747

--- Comment #2 from oplata.kes1 at mail dot ru ---
(In reply to Andrew Pinski from comment #1)
> 
> 32bit floating point has the following characteristics:
> Sign bit: 1 bit
> Exponent width: 8 bits
> Significand precision: 24 bits (23 explicitly stored)
> 
> 
> 5000 is 0x2faf080 which is more than 24bits in precision which means it
> cannot be represented exactly and when you start to add 1 to something which
> is greater than 0xf0 (which is what 1.67772e+07 is), the value stays the
> same and you start to lose precision.

Thank you very much!

[Bug libstdc++/111747] New: Problem with large float list initialization

2023-10-09 Thread oplata.kes1 at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111747

Bug ID: 111747
   Summary: Problem with large float list initialization
   Product: gcc
   Version: 11.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: oplata.kes1 at mail dot ru
  Target Milestone: ---

Created attachment 56085
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56085=edit
*ii file and output

I create a vector on stack of 50 (or 500mln) floats equal to 1.0 and simply add
them.
The sum is not equal to 50 mln (or 5 billions).

5 mln of floats initizalize and sum fine.

The command is

g++ -v -save-temps gcc.cpp && ./a.out

If it is a stack overflow, shouldn't the code fail with stack overflow error?
If not, what is it?

I use GCC 11.4.0 in Ubuntu 22.04 under WSL 2 (!)