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++/11733] New: std::string as static member


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: std::string as static member
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: renz at renzresearch dot com
                CC: gcc-bugs at gcc dot gnu dot org

I think I have isolated a problem in the following 20 lines.  This program 
compiles fine, but the executable causes Segmentation fault (core dumped).  
Each of these points is essential to reproduce the fault:

class a<T> must be a template class;
class a<T> must have std::string as its static member;
class b must have a<T> as its static member;

The program crashes when the static member of class a is accessed.

#include <string>
#include <iostream>
using namespace std;

template <class T> class a {
   public:
      a() {cout << s << endl;}
      static string s;
};
template <class T> string a<T>::s("bug");

class b {
   public:
      b() {}
      static a<int> t;
};
a<int> b::t;

main() {
   const b bob();
   return 0;
}

This is a log of compilation: (but I don't know where to attach the .ii file)

% /usr/bin/g++ -v -save-temps c.c++ -o c
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/u
sr/share/info --enable-shared --enable-threads=posix --disable-checking --
host=i
386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
 /usr/lib/gcc-lib/i386-redhat-linux/3.2/cpp0 -lang-c++ -D__GNUG__=3 -
D__DEPRECAT
ED -D__EXCEPTIONS -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -
D_
_GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -
D__unix
__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -
D__NO_INLINE__
 -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -
D_
_i386__ -D__tune_i386__ c.c++ c.ii
GNU CPP version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) (cpplib) (i386 
Linux/ELF)
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.2
 /usr/include/c++/3.2/i386-redhat-linux
 /usr/include/c++/3.2/backward
 /usr/local/include
 /usr/lib/gcc-lib/i386-redhat-linux/3.2/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-redhat-linux/3.2/cc1plus -fpreprocessed c.ii -quiet -
dump
base c.c++ -version -o c.s
GNU CPP version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) (cpplib) (i386 
Linux/ELF)
GNU C++ version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) (i386-redhat-linux)
        compiled by GNU C version 3.2 20020903 (Red Hat Linux 8.0 3.2-7).
 as -V -Qy -o c.o c.s
GNU assembler version 2.13.90.0.2 (i386-redhat-linux) using BFD version 
2.13.90.
0.2 20020802
 /usr/lib/gcc-lib/i386-redhat-linux/3.2/collect2 --eh-frame-hdr -m elf_i386 -
dyn
amic-linker /lib/ld-linux.so.2 -o c /usr/lib/gcc-lib/i386-redhat-
linux/3.2/../..
/../crt1.o /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crti.o /usr/lib/gcc-
l
ib/i386-redhat-linux/3.2/crtbegin.o -L/usr/lib/gcc-lib/i386-redhat-linux/3.2 -
L/
usr/lib/gcc-lib/i386-redhat-linux/3.2/../../.. c.o -lstdc++ -lm -lgcc_s -lgcc -
l
c -lgcc_s -lgcc /usr/lib/gcc-lib/i386-redhat-linux/3.2/crtend.o /usr/lib/gcc-
lib
/i386-redhat-linux/3.2/../../../crtn.o


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