https://bugs.llvm.org/show_bug.cgi?id=51840
Bug ID: 51840
Summary: call to consteval in immediate invocation context
fails
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
Reduced from https://stackoverflow.com/questions/69166564
The following code fails on clang >= 11.0 (including trunk)
-----
consteval int f(int) { return 1; }
template <typename T>
consteval bool g(T a)
{
int n = f(a); // error here
return true;
}
static_assert(g(2));
-----
with
error: call to consteval function 'f' is not a constant expression
note: read of non-const variable 'a' is not allowed in a constant expression
This seems incorrect. The evaluation of `f` is in an immediate context, i.e.
inside `g` so `f(a)` should be a constant expression. Also, the error only
appears if `g` is a template, and if the result of `f(a)` is stored in a local
variable. GCC accepts the code.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs