[Bug c++/16171] New: Problems when deriving from basic stream classes

mark at emantic dot co dot uk gcc-bugzilla@gcc.gnu.org
Thu Jun 24 07:24:00 GMT 2004


Deriving from basic stream classes fails when: 
The name of the derived class is the same as the base class except that it is 
in a different namespace. 
 
The problem can be demonstrated using the following example (test.cpp): 
 
include <iostream> 
 
namespace mar { 
 
    template <typename charT, 
        typename char_traitsT = std::char_traits<charT> > 
    class basic_iostream 
    :   public std::basic_iostream<charT, char_traitsT> { 
    public: 
        basic_iostream() 
        :   std::basic_iostream<charT, char_traitsT>(0) 
        { 
        } 
    }; 
} 
 
int 
main(int argc, char* argv[]) 
{ 
    mar::basic_iostream<char> strm; 
    return 0; 
} 
 
$ g++ test.cpp 
test.cpp: In instantiation of `mar::basic_iostream<char, 
std::char_traits<char> >': 
test.cpp:20:   instantiated from here 
test.cpp:8: internal error: Segmentation fault 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
$ gcc -v 
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/specs 
Configured with: ../gcc-3.2.3/configure --prefix=/usr --enable-shared 
--enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld 
--verbose --target=i486-slackware-linux --host=i486-slackware-linux 
Thread model: posix 
gcc version 3.2.3 
 
This problem can be avoided by renaming the derived class to something other 
than basic_iostream.

-- 
           Summary: Problems when deriving from basic stream classes
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mark at emantic dot co dot uk
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i486-slackware-linux
  GCC host triplet: i486-slackware-linux
GCC target triplet: i486-slackware-linux


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



More information about the Gcc-bugs mailing list