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

            Bug ID: 110476
           Summary: constexpr floating point regression with -std=c++XX
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pdimov at gmail dot com
  Target Milestone: ---

The following program

#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)

struct X
{
    float f;
};

int main()
{
    constexpr X x{ 3.14f };
    STATIC_ASSERT( x.f == 3.14f );
}

fails under GCC 13/14 with

<source>: In function 'int main()':
<source>:11:24: error: static assertion failed: x.f == 3.14f
   11 |     STATIC_ASSERT( x.f == 3.14f );
      |                    ~~~~^~~~~~~~
<source>:1:42: note: in definition of macro 'STATIC_ASSERT'
    1 | #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
      |                                          ^~~~~~~~~~~
<source>:11:24: note: the comparison reduces to '(3.14000010490417480469e+0l ==
3.1400000000000000001e+0l)'
   11 |     STATIC_ASSERT( x.f == 3.14f );
      |                    ~~~~^~~~~~~~

when compiled with -m32 -std=c++XX under x86 (https://godbolt.org/z/Ghs7j5Teq).
The reason is that -std=c++XX implies -fexcess-precision=standard
(https://godbolt.org/z/zx4rn4j5W).

Previous versions worked fine.

Reply via email to