https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127803
Bug ID: 127803
Summary: immediate invocation of escalated function template
not diagnosed when not a constant expression
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
We accept this test, but it should be rejected:
```
template<int V>
consteval void f () {
(void) (1 / V);
}
template<int V>
constexpr void g () {
(void) f<V>();
}
int
main ()
{
return (g<0>(), 0);
}
```
f<0>() is an immediate invocation that is not a constant expression, because it
divides by zero, so it is immediate-escalating.
g<0> is immediate-escalating, so it becomes an immediate function.
g<0>() in main is thus an immediate invocation. It is not a constant
expression, which makes it immediate-escalating. And it's outside an
immediate-escalating function, which violates [expr.const.imm]/3. But we issue
no diagnostic.