[Bug c++/15050] New: Compiled templated code crashes on delete []

bracken at ansoft dot com gcc-bugzilla@gcc.gnu.org
Wed Apr 21 18:23:00 GMT 2004


I can compile the attached (simple) source file without warnings, but when I 
attempt to run it, it crashes at line 92 (delete [] mData.)  The thing I'm 
attempting to delete is a pointer to a base class.  The pointer is actually 
pointing to an array of objects of a derived class.  The base class has a 
virtual destructor and the derived classes implement their own destructors.  
The base and derived classes are templated.

I've observed this in g++ 3.1, 3.2 and 3.3.2 on RedHat Linux 8, HPUX 11 and 
Solaris 7.  It does not happen if I build with Sun Forte, HP's aCC, or 
Microsoft Visual C++.

To build the program:

g++ -o delcrash delcrash.cxx

Here is the output of gcc -v:

idea(4): gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-
checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

If possible I would appreciate a 3.2 compatible fix since I'm stuck with 3rd 
party libraries built around 3.2.

-- 
           Summary: Compiled templated code crashes on delete []
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bracken at ansoft dot com
                CC: bracken at ansoft dot com,gcc-bugs at gcc dot gnu dot
                    org
 GCC build triplet: g++ -o delcrash delcrash.cxx
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


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



More information about the Gcc-bugs mailing list