https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69054
Bug ID: 69054
Summary: g++ fails to diagnose ambiguous overload resolution
when implicit conversions are involved
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pravasimeet999 at yahoo dot com
Target Milestone: ---
The following program is ill formed C++. But on all versions of g++ it (See
live demo http://melpon.org/wandbox/permlink/EdNNBq5uiMTzDz51 )compiles fine
without any warnings or errors, but diagnostics is required for this program.
It fails in compilation on clang++. (See live demo
http://melpon.org/wandbox/permlink/UjZn64U5oX26xMFI ).
#include <iostream>
struct Base
{
operator double() const { return 0.0; }
};
struct foo
{
foo(const char* c) { }
};
struct Something : public Base
{
void operator[](const foo& f) { }
};
int main()
{
Something d;
d["32"];
return 0;
}
See this stackoverflow question for more details:
http://stackoverflow.com/questions/8914986/should-this-compile-overload-resolution-and-implicit-conversions?rq=1