[Bug c++/14830] New: compiler incorrectly diagnoses ambigous operator overload
iker at research dot att dot com
gcc-bugzilla@gcc.gnu.org
Sat Apr 3 00:47:00 GMT 2004
// main.cpp
#include <string>
using namespace std;
class Test
{
public:
Test()
{
m_s = "test";
}
operator string() const
{
return m_s;
}
operator float() const
{
return 5;
}
private:
string m_s;
};
int
main(int argc, char** argv)
{
Test v;
string s;
s = v;
}
********************************************************
> g++ main.cpp -I . -o test
main.cpp: In function `int main(int, char**)':
main.cpp:32: error: ambiguous overload for `std::string& = Test&' operator
/n/watson/5.1r/i686-pc-linux-gnu/include/c++/3.3/bits/basic_string.h:358: error:
candidates
are: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
_Traits, _Alloc>::operator=(const std::basic_string<_CharT, _Traits,
_Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc =
std::allocator<char>]
/n/watson/5.1r/i686-pc-linux-gnu/include/c++/3.3/bits/basic_string.h:364: error:
std::basic_string<_CharT, _Traits, _Alloc>&
std::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT =
char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
********************************************************
--
Summary: compiler incorrectly diagnoses ambigous operator
overload
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: iker at research dot att dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14830
More information about the Gcc-bugs
mailing list