A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/llvm/llvm-project/issues/48230 below:

consteval function not allowed in default argument to constexpr constructor · Issue #48230 · llvm/llvm-project · GitHub

Extended Description

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 #47058

Best,

Andreas


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4