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

             Bug #: 50710
           Summary: ambiguity problem between bool() and string()
                    operators, when used on a string that's a class member
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: solvedsn...@gmail.com


Created attachment 25478
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25478
The preprocessed test case

struct foo{
  operator bool() {return true;}
  operator string() {return "hello";}
};

foo bar;
string s = bar;

gcc behaves properly, and assings "hello" to s.
However, if s is a member of a struct, gcc gets confused, and complains about
ambiguous overload.

Output of gcc -v:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/src/gcc-4.6-20110819/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --enable-gnu-unique-object
--enable-linker-build-id --with-ppl --enable-cloog-backend=isl --enable-lto
--enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold
--disable-multilib --disable-libssp --disable-libstdcxx-pch
--enable-checking=release
Thread model: posix
gcc version 4.6.1 20110819 (prerelease) (GCC)

How to repeat:
Compile the preprocessed test case with "gcc err.ii"

Reply via email to