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++/67997] New: GCC 5.2.0 fails to link std::cout overloaded functions when -std=c++11 option is used


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67997

            Bug ID: 67997
           Summary: GCC 5.2.0 fails to link std::cout overloaded functions
                    when -std=c++11 option is used
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: all4sanjay at yahoo dot com
  Target Milestone: ---

The sample program below works fine with GCC 4.9.0 and prior versions when used
with -std=c++11 option, but it fails with GCC 5.2.0. In fact it also fails with
Clang 3.7 and Visual Studio 2015 compilers if -std=c++11 option is used. Please
see why it's failing only with 5.2.0 version.

#include <iostream>
#include <sstream>

int main ()
{
   std::stringstream str2;
   str2 << "std::stringstream log message";

   std::cout << str2.str() << std::endl;   //This line works
   std::cout << str2       << std::endl;   //This line fails if -std=c++11
option is used

  return 0;
}

Command Line options to compile the program
Fails: $/gcc/5.2.0/bin/g++ -std=c++11 -o test test.cpp
Works: $/gcc/5.2.0/bin/g++ -o test test.cpp
Works: $/gcc/4.7.2/bin/g++ -std=c++11 -o test test.cpp

Compiler Error:
error: no match for operator<< (operand types are std::ostringstream {aka
std::__cxx11::basic_ostringstream<char>} 


Thanks
Sanjay


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