public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "orion at cora dot nwra.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/49644] New: [ 4.5/4.6 Regression ] post-increment of promoted operand is incorrect.
Date: Tue, 05 Jul 2011 15:35:00 -0000	[thread overview]
Message-ID: <bug-49644-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2011-07-05 15:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 15:35 orion at cora dot nwra.com [this message]
2011-07-05 15:42 ` [Bug c/49644] [4.5/4.6 Regression] " rguenth at gcc dot gnu.org
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 19:48 ` [Bug c/49644] [4.5/4.6 Regression] post-increment of promoted " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-49644-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).