This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/113: Re: egcs c++ bug report
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/113: Re: egcs c++ bug report
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Wed, 15 Mar 2000 10:14:27 +0100
- References: <37BCDC14.E9F1C623@ics.mq.edu.au>
- Resent-Cc: gcc-prs at gcc dot gnu dot org, robbie at ics dot mq dot edu dot au
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, "Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de>
>Number: 113
>Category: c++
>Synopsis: operator delete[] does not receive original array size
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: analyzed
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Mar 15 01:26:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator: Robbie Gates <robbie@ics.mq.edu.au>
>Release: 2.95.2
>Organization:
Macquarie University
>Environment:
>Description:
Original-Message-ID: <37BCDC14.E9F1C623@ics.mq.edu.au>
Date: Fri, 20 Aug 1999 14:39:48 +1000
Hi there,
i think the following is a bug - please find attached the required
stuff from according to http://egcs.cygnus.com/faq.html#bugreport,
as generated by
c++ -v --save-temps bug.cpp
my machine is a redhat 6.0 GNU/Linux system
(robbie@elegia) uname -a
Linux elegia.mpce.mq.edu.au 2.2.5-15 #2 Mon Jul 5 19:31:36 EST 1999 i686
unknown
(robbie@elegia) c++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
On my machine, running the executable from the above compiler produces
8
8
32
328
The executable from c++ -DWORKAROUND bug.cpp produces
8
8
36
36
I believe the latter to be correct, and that the former to be incorrect.
My reasoning is based on section 12.5 (class.free) of CD2 for C++.
I believe the second argument passed to operator delete[] should be
32, not 328, according to clause 9 of 12.5 assuming the compiler
is meeting clause 3 of 12.5. With respect to the footnote, observe that
the static type in the deletion expression is the same as
the actual type of the object.
The workaround code provided seems to solve the problem (at least
in this example :-).
- robbie
>How-To-Repeat:
#include <cstddef>
#include <iostream>
class A
{
public:
void * operator new[] (size_t aS)
{
cout << aS << endl;
return ::operator new(aS);
}
void operator delete[] (void * aPtr, size_t aS)
{
cout << aS << endl;
::operator delete(aPtr);
}
#ifdef WORKAROUND
~A()
{
}
#endif
};
class B : public A
{
int x;
};
int main()
{
A * a = new A[4];
delete[] a;
B * b = new B[4];
delete[] b;
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: