This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/49644] New: [ 4.5/4.6 Regression ] post-increment of promoted operand is incorrect.
- From: "orion at cora dot nwra.com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 5 Jul 2011 15:34:38 +0000
- Subject: [Bug c/49644] New: [ 4.5/4.6 Regression ] post-increment of promoted operand is incorrect.
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49644
Summary: [ 4.5/4.6 Regression ] post-increment of promoted
operand is incorrect.
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: orion@cora.nwra.com
#include <stdio.h>
#include <complex.h>
int main(int argc, char *argv[]) {
double data[6] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0},*d;
double complex *c, s = 3.0 + 0.0I;
int i;
d=data;
for (i = 0; i<6; i++) {
printf("c(%p), d(%p)=%lf\n",c,d,*d);
*c++ = *d++ * s;
}
return 0;
}
With gcc 4.4.5 (compiles without warnings with -Wall):
c(0x7fff16e86a00), d(0x7fff16e868d0)=1.000000
c(0x7fff16e86a10), d(0x7fff16e868d8)=2.000000
c(0x7fff16e86a20), d(0x7fff16e868e0)=3.000000
c(0x7fff16e86a30), d(0x7fff16e868e8)=4.000000
c(0x7fff16e86a40), d(0x7fff16e868f0)=5.000000
c(0x7fff16e86a50), d(0x7fff16e868f8)=6.000000
With gcc 4.5.1 and 4.6.0:
c(0x7fff5411f2f0), d(0x7fff5411f1c0)=1.000000
c(0x7fff5411f300), d(0x7fff5411f1d0)=3.000000
c(0x7fff5411f310), d(0x7fff5411f1e0)=5.000000
c(0x7fff5411f320), d(0x7fff5411f1f0)=0.000000
c(0x7fff5411f330), d(0x7fff5411f200)=0.000000
c(0x7fff5411f340), d(0x7fff5411f210)=0.000000
It appears that the right hand side pointer is being incremented at the rate
of its promoted size. If you remove the " * s" from the increment line, the
code works as expected. Same problem with 32-bit and 64-bit machines.