[llvm-bugs] [Bug 39242] New: accepts-invalid when a constexpr function is called in a conditional

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 10 04:22:26 PDT 2018


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

            Bug ID: 39242
           Summary: accepts-invalid when a constexpr function is called in
                    a conditional
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rakuco at FreeBSD.org
                CC: llvm-bugs at lists.llvm.org

constexpr bool always_false() { return false; }
int f() { return 1; }
constexpr int g() {
  if (!always_false()) {}
  return f();
}

The excerpt above fails on GCC and MSVC. clang++ also complains when the
conditional clause is removed:

<source>:3:15: error: constexpr function never produces a constant expression
[-Winvalid-constexpr]
constexpr int g() {
              ^
<source>:5:10: note: non-constexpr function 'f' cannot be used in a constant
expression
  return f();
         ^
<source>:2:5: note: declared here
int f() { return 1; }
    ^

-- 
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/20181010/266be064/attachment.html>


More information about the llvm-bugs mailing list