| Issue |
165369
|
| Summary |
[Clang] Clang and GCC diverge on array reference overload resolution with int const(&)[] vs int const(&)[1]
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
Xniao
|
**_Generated by Fuzzer._**
GCC correctly accepts the call as unambiguous, selecting the more specific [1] overload, while Clang incorrectly rejects it with an "ambiguous call" error.
Reproducer: https://godbolt.org/z/4YTerK8Ws
Program:
```cpp
int f2(int const (&)[]) { return 1; }
int f2(int const (&)[1]) {
const int size = 1;
int array[size] = {42};
if (array[0] > 0) {
int value_2 = f2(array);
return value_2;
}
return 2;
}
int main() {
if (f2({}) != 1) return -1;
if (f2({1}) != 2) return -1;
return 0;
}
```
Clang rejects it with following error message:
```bash
<source>:6:19: error: call to 'f2' is ambiguous
6 | int value_2 = f2(array);
| ^~
<source>:1:5: note: candidate function
1 | int f2(int const (&)[]) { return 1; }
| ^
<source>:2:5: note: candidate function
2 | int f2(int const (&)[1]) {
| ^
1 error generated.
Compiler returned: 1
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs