llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

ill-formed program with ambiguity of overload resolution accepted

Open Fedr opened this issue 2 years ago • 4 comments

This program

#include <vector>

struct A {};

void func(std::vector<int>) {}
void func(std::vector<A>);

int main() {
    func({ 4 });
}

is rejected by GCC and MSVC due to call of overloaded 'func(<brace-enclosed initializer list>)' is ambiguous, but Clang accepts the program, which seems incorrect since there is no IFNDR here. Online demo: https://godbolt.org/z/Prz4YcsW5

Explanation why the program is ill-formed: https://stackoverflow.com/a/77979372/7325599 GCC developers support it: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884

Fedr avatar Feb 13 '24 08:02 Fedr

@llvm/issue-subscribers-clang-frontend

Author: None (Fedr)

This program ``` #include <vector>

struct A {};

void func(std::vector<int>) {} void func(std::vector<A>);

int main() { func({ 4 }); }

is rejected by GCC and MSVC due to `call of overloaded 'func(&lt;brace-enclosed initializer list&gt;)' is ambiguous`, but Clang accepts the program, which seems incorrect since there is no IFNDR here. Online demo: https://godbolt.org/z/Prz4YcsW5

Explanation why the program is ill-formed: https://stackoverflow.com/a/77979372/7325599
GCC developers support it: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113884
</details>

llvmbot avatar Feb 13 '24 16:02 llvmbot

I had mentioned the clang bug was already filed as https://github.com/llvm/llvm-project/issues/28016 ...

pinskia avatar Feb 13 '24 16:02 pinskia

I would like to take up this issue. Started analysing. I am new to llvm project. @EugeneZelenko, any suggestions where would be really helpful :) I am starting with SemaOverload.cpp. Am I in the right path?

akshaykumars614 avatar Feb 13 '24 16:02 akshaykumars614

I would like to take up this issue. Started analysing. I am new to llvm project. @EugeneZelenko, any suggestions where would be really helpful :)

Please see the duplicate issue. It is not clear to me whether this is a good beginner issue or not. I have not dug into it and I don't know if I will have time to.

We do have a "good first issue" label: https://github.com/llvm/llvm-project/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+

shafik avatar Feb 13 '24 17:02 shafik