This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13308] C++ operator ambiguity error


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-05 00:19 -------
Here is the warning I get on the mainline (yes the warning is fixed already):
test_class.cpp: In function `int whatever(CDSPString*, int)':
test_class.cpp:53: error: ISO C++ says that these are ambiguous, even though the worst 
conversion for the first is better than the worst conversion for the second:
test_class.cpp:29: note: candidate 1: CDSPString operator+(const char*, const CDSPString&)
test_class.cpp:53: note: candidate 2: operator+(char*, int) <built-in>

The problem is that bool can and will be converted into an int.
One thing you can do is add a constructor for char* and then have the operator+ be const 
CDSPString&, const CDSPString&.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13308


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]