[llvm-bugs] [Bug 47714] New: Pointer to consteval function not allowed in a constant expression

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 2 15:49:16 PDT 2020


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

            Bug ID: 47714
           Summary: Pointer to consteval function not allowed in a
                    constant expression
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yaghmour.shafik at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The following example is given both in the current C++ draft standard:
http://eel.is/c++draft/expr.const#11 and the immediate functions proposal:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1073r3.html

  consteval int f() { return 42; }
  consteval auto g() { return f; }
  consteval int h(int (*p)() = g()) { return p(); }
  constexpr int r = h();                          // OK

and although examples not normative AFAICT this is meant to be valid but clang
rejects this although gcc does accept it, see the following godbolt:
https://godbolt.org/z/WW7G9q

-- 
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/20201002/92b0c4df/attachment.html>


More information about the llvm-bugs mailing list