| Issue |
75843
|
| Summary |
miscomputation of function type taking address of function with `decltype(auto)` return type deduced as const-qualified
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
zygoloid
|
Testcase:
```c++
const int n = 0;
template <class = void>
decltype(auto) g() {
return n;
}
const int (&r)() = g<>;
```
The initialization of `r` fails, with clang complaining that it can't match `decltype(auto)` against `const `int`:
```console
<source>:9:24: error: address of overloaded function 'g' does not match required type 'const int ()'
9 | const int (&r)() = g<>;
| ^~~
<source>:4:16: note: candidate template ignored: could not match 'decltype(auto)' against 'const int'
4 | decltype(auto) g() {
| ^
```
This works fine if the `const` is removed in both places -- not all address-of-overloaded-function deductions fail with `decltype(auto)`. Also, if `const` is just removed from `r`, we get:
```console
<source>:8:14: error: address of overloaded function 'g' does not match required type 'int ()'
8 | int (&r)() = g<>;
| ^~~
<source>:4:16: note: candidate template ignored: could not match 'const int ()' against 'int ()'
4 | decltype(auto) g() {
| ^
```
... so Clang *does* know the return type is `const int`. Perhaps we're incorrectly removing top-level cv-qualifiers from the deduced return type at some stage?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs