public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108223] New: GCC reject QNaN in constant expressions
@ 2022-12-25 15:04 nikolasklauser at berlin dot de
  2022-12-25 18:30 ` [Bug c++/108223] GCC rejects " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nikolasklauser at berlin dot de @ 2022-12-25 15:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108223
           Summary: GCC reject QNaN in constant expressions
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nikolasklauser at berlin dot de
  Target Milestone: ---

GCC rejects the following code with "error: '__builtin_fmax(+QNaN, +QNaN)' is
not a constant expression" even though it's perfectly defined behaviour.

test code (Godbolt: https://godbolt.org/z/1hfxM9PEW):

constexpr bool test() {
  auto val = __builtin_fmax(__builtin_nan(""), __builtin_nan(""));

  return true;
}

static_assert(test());

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

* [Bug c++/108223] GCC rejects QNaN in constant expressions
  2022-12-25 15:04 [Bug c++/108223] New: GCC reject QNaN in constant expressions nikolasklauser at berlin dot de
@ 2022-12-25 18:30 ` pinskia at gcc dot gnu.org
  2022-12-25 18:33 ` [Bug c++/108223] GCC rejects QNaN in __builtin_fmax constant expression pinskia at gcc dot gnu.org
  2022-12-25 18:38 ` nikolasklauser at berlin dot de
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-25 18:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
__builtin_fmax does not have to be a constant expression as it is an extension
...

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

* [Bug c++/108223] GCC rejects QNaN in __builtin_fmax constant expression
  2022-12-25 15:04 [Bug c++/108223] New: GCC reject QNaN in constant expressions nikolasklauser at berlin dot de
  2022-12-25 18:30 ` [Bug c++/108223] GCC rejects " pinskia at gcc dot gnu.org
@ 2022-12-25 18:33 ` pinskia at gcc dot gnu.org
  2022-12-25 18:38 ` nikolasklauser at berlin dot de
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-25 18:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
That being said this works:
#include <cmath>
constexpr bool test() {
  auto val = std::max(__builtin_nan(""), __builtin_nan(""));

  return true;
}

static_assert(test());

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

* [Bug c++/108223] GCC rejects QNaN in __builtin_fmax constant expression
  2022-12-25 15:04 [Bug c++/108223] New: GCC reject QNaN in constant expressions nikolasklauser at berlin dot de
  2022-12-25 18:30 ` [Bug c++/108223] GCC rejects " pinskia at gcc dot gnu.org
  2022-12-25 18:33 ` [Bug c++/108223] GCC rejects QNaN in __builtin_fmax constant expression pinskia at gcc dot gnu.org
@ 2022-12-25 18:38 ` nikolasklauser at berlin dot de
  2 siblings, 0 replies; 4+ messages in thread
From: nikolasklauser at berlin dot de @ 2022-12-25 18:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Nikolas Klauser <nikolasklauser at berlin dot de> ---
It doesn't have to work, but it works for some inputs, so I would expect that
it works for all. https://godbolt.org/z/KsrjEP77c

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

end of thread, other threads:[~2022-12-25 18:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-25 15:04 [Bug c++/108223] New: GCC reject QNaN in constant expressions nikolasklauser at berlin dot de
2022-12-25 18:30 ` [Bug c++/108223] GCC rejects " pinskia at gcc dot gnu.org
2022-12-25 18:33 ` [Bug c++/108223] GCC rejects QNaN in __builtin_fmax constant expression pinskia at gcc dot gnu.org
2022-12-25 18:38 ` nikolasklauser at berlin dot de

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).