public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jessica_han@hp.com
To: gcc-gnats@gcc.gnu.org
Subject: optimization/6686: IA64 GCC 3.1 Incorrect run time result at -O1
Date: Thu, 16 May 2002 16:36:00 -0000	[thread overview]
Message-ID: <20020516232603.8796.qmail@sources.redhat.com> (raw)


>Number:         6686
>Category:       optimization
>Synopsis:       IA64 GCC 3.1 Incorrect run time result at -O1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 16 16:36:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     jessica_han@hp.com
>Release:        3.1
>Organization:
>Environment:
IA64 Linux
>Description:
Incorrect behavior at -O1 

Before change, j points to: 0x80000fffffffbac0
After change, j points to: 0x6000000000000d90
Address of i (which j is supposed to equal) is: 0x6000000000000d90
value of j is: 0x80000fffffffbac0, address of i is  0x6000000000000d90
*ox.oy.j=10, expect 5
>How-To-Repeat:
g++ -O1 bug1.C
./a.out
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bug1.C"
Content-Disposition: inline; filename="bug1.C"

// failed in -O1

#include <stdio.h>

static int i = 5;

int main()
{
  const class X
  {
   public:
     mutable int i;    //mutable data-member
     class Y
     {
       public:
        mutable volatile int *j;   //j is a pointer to mutable volatile int
        void Change_j() const
        {
            j = &::i;
        }
     };
     Y oy;
    X() : i(10) { }
   }ox;
   ox.oy.j = (volatile int*)&ox.i;
   printf("Before change, j points to: %p\n",ox.oy.j);
   ox.oy.Change_j();
   printf("After change, j points to: %p\n",ox.oy.j);
   printf("Address of i (which j is supposed to equal) is: %p\n",&i);
   printf("value of j is: %p, address of i is  %p\n",ox.oy.j, &i);
   if(*ox.oy.j != 5)
      printf("*ox.oy.j=%d, expect 5  \n", *ox.oy.j);
}


             reply	other threads:[~2002-05-16 23:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-16 16:36 jessica_han [this message]
2003-05-03  0:23 falk.hueffner

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=20020516232603.8796.qmail@sources.redhat.com \
    --to=jessica_han@hp.com \
    --cc=gcc-gnats@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).