This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/34169] New: Bad code generated with -O2
- From: "unaiur at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Nov 2007 00:06:04 -0000
- Subject: [Bug tree-optimization/34169] New: Bad code generated with -O2
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1
--enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug
--enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
$ gcc -O2 -w p.c -o p ; ./p
Bad
$ gcc -O2 -fno-tree-pre -w p.c -o p ; ./p
$ gcc -O2 -fno-strict-aliasing -w p.c -o p ; ./p
$ cat p.c
int bmemcmp(void *a1, void *a2, unsigned len)
{
int dwlen = len / 4;
while (dwlen)
{
int res = *(int *)a1 - *(int *)a2;
if (res)
return res;
--dwlen;
++*(int **)&a1;
++*(int **)&a2;
}
return 0;
}
int main(int argc, char *argv[])
{
int *p1 = (int*)calloc(sizeof(int), 1024 * 1024 * 4);
int *p2 = (int*)calloc(sizeof(int), 1024 * 1024 * 4);
p1[3] = 1;
if (bmemcmp(p1, p2, 1024 * 1024 * 4) == 0)
printf("Bad\n");
return 0;
}
--
Summary: Bad code generated with -O2
Product: gcc
Version: 4.1.3
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: unaiur at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34169