public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/49644] New: [ 4.5/4.6 Regression ] post-increment of promoted operand is incorrect.
@ 2011-07-05 15:35 orion at cora dot nwra.com
  2011-07-05 15:42 ` [Bug c/49644] [ 4.5/4.6 Regression ] post-increment of promoted to complex " orion at cora dot nwra.com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: orion at cora dot nwra.com @ 2011-07-05 15:35 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-08-01 14:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-05 15:35 [Bug c/49644] New: [ 4.5/4.6 Regression ] post-increment of promoted operand is incorrect orion at cora dot nwra.com
2011-07-05 15:42 ` [Bug c/49644] [ 4.5/4.6 Regression ] post-increment of promoted to complex " orion at cora dot nwra.com
2011-07-05 15:42 ` [Bug c/49644] [4.5/4.6 Regression] post-increment of promoted " rguenth at gcc dot gnu.org
2011-07-05 19:48 ` jakub at gcc dot gnu.org
2011-07-05 20:02 ` orion at cora dot nwra.com
2011-07-07  9:55 ` [Bug c/49644] [4.5/4.6/4.7 " orion at cora dot nwra.com
2011-07-07  9:55 ` jakub at gcc dot gnu.org
2011-07-07 19:11 ` jakub at gcc dot gnu.org
2011-07-07 19:14 ` jakub at gcc dot gnu.org
2011-07-07 19:20 ` jakub at gcc dot gnu.org
2011-07-07 19:42 ` jakub at gcc dot gnu.org
2011-07-07 19:43 ` jakub at gcc dot gnu.org
2011-07-19 13:08 ` [Bug c/49644] [4.5 " jakub at gcc dot gnu.org
2011-07-19 13:09 ` jakub at gcc dot gnu.org
2011-07-19 13:49 ` jakub at gcc dot gnu.org
2011-08-01 14:52 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).