Open
Description
Compiled with -std=c++20 -fsyntax-only
https://godbolt.org/z/16vaW6c6M:
extern int x;
template<void* p>
void f() {
[]<typename = void>() {
static_assert(p == &x);
}();
}
int main() {
f<(void*)&x>();
}
<source>:6:23: error: conversion from 'int *' to 'void *' is not allowed in a converted constant expression
6 | static_assert(p == &x);
| ^
<source>:5:5: note: in instantiation of function template specialization 'f()::(anonymous class)::operator()<void>' requested here
5 | []<typename = void>() {
| ^
<source>:11:5: note: in instantiation of function template specialization 'f<&x>' requested here
11 | f<(void*)&x>();
| ^
<source>:3:16: note: template parameter is declared here
3 | template<void* p>
| ^
Removing the <typename = void>
(i.e., making it a non-generic lambda) makes this compile.