public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110476] New: constexpr floating point regression with -std=c++XX
@ 2023-06-29  6:52 pdimov at gmail dot com
  2023-06-29  8:03 ` [Bug c++/110476] " pdimov at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pdimov at gmail dot com @ 2023-06-29  6:52 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-29 11:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-29  6:52 [Bug c++/110476] New: constexpr floating point regression with -std=c++XX pdimov at gmail dot com
2023-06-29  8:03 ` [Bug c++/110476] " pdimov at gmail dot com
2023-06-29 11:02 ` pdimov at gmail dot com
2023-06-29 11:12 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).