This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Placement new[] weirdness
- To: (Mike Stump) <mrs at wrs dot com>
- Subject: Re: Placement new[] weirdness
- From: Andrey Slepuhin <pooh at msu dot ru>
- Date: Fri, 16 Jul 1999 02:25:46 +0400 (MEDT)
- Cc: egcs at egcs dot cygnus dot com
- Organization: Moscow State University Network (MSUnet)
On 15-Jul-99 Mike Stump wrote:
[snip]
> Yes, bug you failed to mention a single problem (in the form of a
> testcase) that you have. Sorry, we cannot help you without one.
Well, the following program:
#include <iostream>
#include <new>
struct X
{
X()
{}
~X()
{}
};
void main ()
{
#define N 5
char p[N*sizeof(X)];
cout<<(void*)p<<endl;
X* p1=new(p) X[N];
cout<<p1<<endl;
}
prints on i586-unknown-linux-gnu:
0xbffff710
0xbffff714
This seems to be not conforming to C++ draft, clause 18.4.1.3 (though conforming
to 5.3.4). Accessing data of array p1 may lead to stack corruption.
Andrey.