[llvm-bugs] [Bug 48886] New: consteval function not allowed in default argument to constexpr constructor

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 26 07:00:23 PST 2021


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

            Bug ID: 48886
           Summary: consteval function not allowed in default argument to
                    constexpr constructor
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: src at andyf.de
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Hello,

the following valid code is currently rejected by Clang 11 and trunk
(https://godbolt.org/z/645McM):

consteval int Fun() { return 0; }

struct Test {
  constexpr Test(int loc = Fun()) {}
};

Test t{};

The error is:

<source>:4:28: error: cannot take address of consteval function 'Fun' outside
of an immediate invocation
  constexpr Test(int loc = Fun()) {}
                           ^
<source>:1:15: note: declared here
consteval int Fun() { return 0; }
              ^
1 error generated.
Compiler returned: 1


I had a brief communication with Richard Smith who confirmed that the code
above is valid.


I assume this bug is similar to https://bugs.llvm.org/show_bug.cgi?id=47714


Best,

   Andreas

-- 
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/20210126/b515dd2d/attachment-0001.html>


More information about the llvm-bugs mailing list