The following program prints a hex address.  I expected it to print "Hello, 
world"

nm | c++filt|grep operator shows that the operator<< used is:

std::basic_ostream<char, std::char_traits<char> >::operator<<(void const*)

I expected operator<<(char const*)

This is with Fedora's gcc-4.0.1-3.i386.rpm

The program:

#include <sstream>
#include <stdio.h>

struct cerror {
    ~cerror() { printf ("%s\n", s.str().c_str()); }
    mutable std::ostringstream s;
};


int main()
{
    cerror().s << "Hello, world\n";
    return 0;
}

-- 
           Summary: Incorrect overload resolution on mutable field.
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: suckfish at ihug dot co dot nz
                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=22566

Reply via email to