public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15050] New: Compiled templated code crashes on delete []
@ 2004-04-21 18:23 bracken at ansoft dot com
2004-04-21 18:26 ` [Bug c++/15050] " bracken at ansoft dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: bracken at ansoft dot com @ 2004-04-21 18:23 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/15050] Compiled templated code crashes on delete []
2004-04-21 18:23 [Bug c++/15050] New: Compiled templated code crashes on delete [] bracken at ansoft dot com
@ 2004-04-21 18:26 ` bracken at ansoft dot com
2004-04-21 18:33 ` bracken at ansoft dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: bracken at ansoft dot com @ 2004-04-21 18:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bracken at ansoft dot com 2004-04-21 18:13 -------
Created an attachment (id=6133)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6133&action=view)
Complete compilable source file
This is the source code for the program that crashes.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15050
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/15050] Compiled templated code crashes on delete []
2004-04-21 18:23 [Bug c++/15050] New: Compiled templated code crashes on delete [] bracken at ansoft dot com
2004-04-21 18:26 ` [Bug c++/15050] " bracken at ansoft dot com
@ 2004-04-21 18:33 ` bracken at ansoft dot com
2004-04-21 18:57 ` bangerth at dealii dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: bracken at ansoft dot com @ 2004-04-21 18:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bracken at ansoft dot com 2004-04-21 18:23 -------
I just built gcc 3.4.0 on Linux. It also compiles this code "successfully",
but the compiled program crashes in the exact same place.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15050
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/15050] Compiled templated code crashes on delete []
2004-04-21 18:23 [Bug c++/15050] New: Compiled templated code crashes on delete [] bracken at ansoft dot com
2004-04-21 18:26 ` [Bug c++/15050] " bracken at ansoft dot com
2004-04-21 18:33 ` bracken at ansoft dot com
@ 2004-04-21 18:57 ` bangerth at dealii dot org
2004-04-21 19:46 ` bracken at ansoft dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2004-04-21 18:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-04-21 18:33 -------
This code is invalid. 5.3.5/2 states that the argument to delete[] shall
be a pointer that resulted from a previous array-new expression. You
violate this here.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15050
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/15050] Compiled templated code crashes on delete []
2004-04-21 18:23 [Bug c++/15050] New: Compiled templated code crashes on delete [] bracken at ansoft dot com
` (2 preceding siblings ...)
2004-04-21 18:57 ` bangerth at dealii dot org
@ 2004-04-21 19:46 ` bracken at ansoft dot com
2004-04-21 20:04 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: bracken at ansoft dot com @ 2004-04-21 19:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bracken at ansoft dot com 2004-04-21 19:27 -------
How so? The function OctNode<T, kD>::SetUserData() does an array new:
mData = new OctNodeUserData<T, kD>[kD];
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15050
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/15050] Compiled templated code crashes on delete []
2004-04-21 18:23 [Bug c++/15050] New: Compiled templated code crashes on delete [] bracken at ansoft dot com
` (3 preceding siblings ...)
2004-04-21 19:46 ` bracken at ansoft dot com
@ 2004-04-21 20:04 ` pinskia at gcc dot gnu dot org
2004-04-21 21:20 ` bangerth at dealii dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-21 20:04 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-21 19:59 -------
Invalid as you start with one type for the array and then casted it to another implicitly and then you
deleted in a different type so it assumes a different length so again this is invalid.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15050
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/15050] Compiled templated code crashes on delete []
2004-04-21 18:23 [Bug c++/15050] New: Compiled templated code crashes on delete [] bracken at ansoft dot com
` (4 preceding siblings ...)
2004-04-21 20:04 ` pinskia at gcc dot gnu dot org
@ 2004-04-21 21:20 ` bangerth at dealii dot org
2005-07-29 11:49 ` pinskia at gcc dot gnu dot org
2005-07-29 11:49 ` pinskia at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2004-04-21 21:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-04-21 20:59 -------
Exactly.
new OctNodeUserData<...> ()
has type OctNodeUserData*, whereas the type in the delete expression
has type OctNode<...>*
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15050
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/15050] Compiled templated code crashes on delete []
2004-04-21 18:23 [Bug c++/15050] New: Compiled templated code crashes on delete [] bracken at ansoft dot com
` (5 preceding siblings ...)
2004-04-21 21:20 ` bangerth at dealii dot org
@ 2005-07-29 11:49 ` pinskia at gcc dot gnu dot org
2005-07-29 11:49 ` pinskia at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-29 11:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-29 11:49 -------
Mark as a dup of bug 22609.
*** This bug has been marked as a duplicate of 22609 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15050
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/15050] Compiled templated code crashes on delete []
2004-04-21 18:23 [Bug c++/15050] New: Compiled templated code crashes on delete [] bracken at ansoft dot com
` (6 preceding siblings ...)
2005-07-29 11:49 ` pinskia at gcc dot gnu dot org
@ 2005-07-29 11:49 ` pinskia at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-29 11:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-29 11:48 -------
Reopening to ...
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15050
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-07-29 11:49 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-21 18:23 [Bug c++/15050] New: Compiled templated code crashes on delete [] bracken at ansoft dot com
2004-04-21 18:26 ` [Bug c++/15050] " bracken at ansoft dot com
2004-04-21 18:33 ` bracken at ansoft dot com
2004-04-21 18:57 ` bangerth at dealii dot org
2004-04-21 19:46 ` bracken at ansoft dot com
2004-04-21 20:04 ` pinskia at gcc dot gnu dot org
2004-04-21 21:20 ` bangerth at dealii dot org
2005-07-29 11:49 ` pinskia at gcc dot gnu dot org
2005-07-29 11:49 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).