I was trying to build a simple app and use the std::string to build an ofstream
as allowed by C++-0X.

The source and header allows this.  You can compile but not link.

I've verified this on powerpc-apple-darwin7.9.0 and on x86_64-linux-unknown.

I think symbols are getting stripped out of the final library.

Here's a test case test_string_fstream.cpp
--------------------------------------------------------------

// ./bin/bin/g++ -std=c++0x -o test_string_fstream test_string_fstream.cpp

#include <string>
#include <fstream>

int
main()
{
  std::string name = "test.dat";
  std::ofstream stream( name );
}

--------------------------------------------------------------

MacOSX:~ ed$ ./bin/bin/g++ -std=c++0x -o test_string_fstream
test_string_fstream.cpp
/usr/bin/ld: Undefined symbols:
std::basic_ofstream<char, std::char_traits<char>
>::basic_ofstream(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::_Ios_Openmode)

Here is the compiler specifics:

MacOSX:~ ed$ ./bin/bin/g++ -v                                                   
Using built-in specs.
Target: powerpc-apple-darwin7.9.0
Configured with: ../gcc/configure --prefix=/Users/ed/bin --with-gmp=/usr/local
--with-mpfr=/usr/local --enable-languages=c,c++,fortran,objc,obj-c++ :
(reconfigured) ../gcc/configure --prefix=/Users/ed/bin --with-gmp=/usr/local
--with-mpfr=/usr/local --enable-languages=c,c++,fortran,objc,obj-c++
--no-create --no-recursion
Thread model: posix
gcc version 4.5.0 20090501 (experimental) (GCC) 

Thanks,

Ed


-- 
           Summary: Unable to link fstream open and ctor with std::string
                    argument.
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: 3dw4rd at verizon dot net


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

Reply via email to