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++/14419] New: Request clarification of ambiguous overload error.


The attached code gives an ambiguous overload error on line 22, the full text of
which is pasted below. I am not sure whether this is a bug, but it seems strange
to me that gcc things there is ambiguity when multiple conversions are available
if one of the conversions is an exact match for the type required (std::string)
and the other two available (int, and bool) are not really the right type for
the other two constructors which take "const _CharT *" and "_CharT" respectively.

ambiguous_test.cpp: In function `int main()':
ambiguous_test.cpp:22: error: ambiguous overload for 'operator=' in 's2 = a'
/usr/include/c++/3.3.2/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>]
/usr/include/c++/3.3.2/bits/basic_string.h:361: error:                 
   std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, 
   _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char, _Traits = 
   std::char_traits<char>, _Alloc = std::allocator<char>] <near match>
/usr/include/c++/3.3.2/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: Request clarification of ambiguous overload error.
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alriddoch at zepler dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


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


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