-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constevalC++20 constevalC++20 consteval
Description
First example:
consteval void f(int) {}
template<typename T>
struct G {
void g() {
::f(T::fn());
}
};https://godbolt.org/z/qYfs8jzon
<source>:6:9: error: cannot take address of consteval function 'f' outside of an immediate invocation
6 | ::f(T::fn());
| ^
<source>:1:16: note: declared here
1 | consteval void f(int) {}
| ^
Second example:
consteval void f(int) {}
template<typename T>
void g() {
auto l = []{
::f(T::fn());
};
}
struct Y {
static int fn();
};
template void g<Y>();https://godbolt.org/z/zrsEqPa5s
<source>:6:9: error: call to consteval function 'f' is not a constant expression
6 | ::f(T::fn());
| ^
<source>:14:15: note: in instantiation of function template specialization 'g<Y>' requested here
14 | template void g<Y>();
| ^
<source>:6:13: note: non-constexpr function 'fn' cannot be used in a constant expression
6 | ::f(T::fn());
| ^
<source>:11:16: note: declared here
11 | static int fn();
| ^
(l's closure type's call operator should be an immediate lambda since it is an immediate-escalating function containing an immediate-escalating expression, and this should be accepted since it is never called (barring it never producing a constant expression, but that should complain about something else, and not in C++23: P2448R2))
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constevalC++20 constevalC++20 consteval