Issue |
145012
|
Summary |
[clang] Bogus error about converting pointer to void* when using `void*` constant parameter/NTTP and a generic lambda
|
Labels |
clang
|
Assignees |
|
Reporter |
MitalAshok
|
Compiled with `-std=c++20 -fsyntax-only` <https://godbolt.org/z/f8roYGY5b>:
```c++
extern int x;
template<void* p>
constexpr 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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs