This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/35559] New: aliasing property of global operator new is not taken advantage of
- From: "xinliangli at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Mar 2008 20:27:25 -0000
- Subject: [Bug middle-end/35559] New: aliasing property of global operator new is not taken advantage of
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Global Operator new returns a memory disjoint from previous allocated memory
from operator new -- this is the requirement even for user provided version.
See standard 3.7.3.1 for details.
This is not taken advantage of by gcc -- there might be a duplicate for this --
since this looks like a major problem -- open it for reference.
Compile the following program with -DNEW and -DMALLOC, gcc is able to hoist
v1[i] for the latter, but not the new case.
Example:
#include <stdlib.h>
#include <vector>
using namespace std;
int main ()
{
int i,j;
#ifdef NEW
int* v1 = new int(100);
int* v2 = new int(100);
for (i = 0; i < 100; i++)
{ v1[i] = 0; v2[i] = 0; }
#elif defined(MALLOC)
int* v1 = (int*) malloc(400);
int* v2 = (int*) malloc(400);
for (i = 0; i < 100; i++)
{ v1[i] = 0; v2[i] = 0; }
#endif
for ( i = 0; i < 100; i++)
v1[i] = i;
for (i = 0; i < 100; i++)
{
for (j = 0; j < 100; j++)
{
v2[j] += v1[i];
}
}
return v2[1];
}
--
Summary: aliasing property of global operator new is not taken
advantage of
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: xinliangli at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35559