[Bug c++/33407] C++ operator new and new expression do not change dynamic type
rguenth at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Sep 12 10:14:00 GMT 2007
------- Comment #2 from rguenth at gcc dot gnu dot org 2007-09-12 10:13 -------
main should call init(), but it doesn't make a difference for the IL. The
bug is wrong-IL for me only at the moment, but nothing prevents the two stores
from being reordered.
Here's one that abort()s at runtime on i686 with -O2 for me: (same trick
as in PR29286, trick LIM into reordering the stores :))
extern "C" void * malloc(__SIZE_TYPE__);
extern "C" void abort(void);
void *p;
void __attribute__((noinline)) init(void)
{
p = malloc(4);
}
inline void *operator new(__SIZE_TYPE__)
{
return p;
}
inline void operator delete (void*) {}
int * __attribute__((noinline)) doit(int n)
{
float *q;
int *r;
for (int i=0; i<n; ++i)
{
q = new float;
*q = 1.0;
delete q;
r = new int;
*r = 1;
}
return r;
}
int main()
{
init();
if (*doit(1) != 1)
abort();
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33407
More information about the Gcc-bugs
mailing list