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

            Bug ID: 85647
           Summary: gcc 5.4.0 always takes c++11 string
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Sagar2.shah at citi dot com
  Target Milestone: ---

Please refer below sample program - 
$ cat string.cpp
#include <iostream>
#include <string>

void foo(const std::string& arg)
{
    std::cout << "foo [" << arg << "]" << std::endl;
}

int main()
{
    std::string arg("123");
    foo(arg);
}

$ g++ --version
_g++ (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ -std=c++98 string.cpp        
$ nm a.out | grep foo                                                           
0000000000400d30 t
_GLOBAL__sub_I__Z3fooRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000400c18 T _Z3fooRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
$ rm a.out
rm: remove regular file `a.out'? y
$ g++ -std=c++14 string.cpp                                                     
$ nm a.out | grep foo
0000000000400d30 t
_GLOBAL__sub_I__Z3fooRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000400c18 T _Z3fooRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

When I compile above program with -std=c++14 and -std=c++98, I see that it
resolves std::string to __cxx1112basic_stringIcSt11char_traits in both the
cases.

I have a legacy library compiled with gcc 4.4.7 and takes string/std::map
arguments and if my application compiled with gcc 5.4.0 and with c++98 flag on
tries to link with that library i run into linker error, as the legacy library
is not able to understand c++11 string.

Should't gcc resolve std::string to c++98 string.? or 5.4.0 has stopped
supporting c++98 and is not backward compatible?

Reply via email to