[llvm-bugs] [Bug 40324] New: floating point NaN generation isn't considered a constant expression

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 15 11:27:48 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40324

            Bug ID: 40324
           Summary: floating point NaN generation isn't considered a
                    constant expression
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Darrell.Wright at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The following code isn't considered constexpr in clang/apple clang but does
work in gcc.  I could not find anything in the standard(not an exhaustive look)
that indicated that this would not be allowed in a constant expression.  The
worry is that if this is correct I would have to create code to ensure it
cannot happen.  I tried trunk and latest Apple Clang with 11,14,17, and 2a
standards as arguments.

#include <limits>
constexpr bool cx() {
  return std::numeric_limits<double>::infinity() -
         std::numeric_limits<double>::infinity();
}
static_assert(cx(), "");

https://gcc.godbolt.org/z/DxFd2F

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190115/6e887069/attachment.html>


More information about the llvm-bugs mailing list