optimization/6686: IA64 GCC 3.1 Incorrect run time result at -O1

jessica_han@hp.com jessica_han@hp.com
Thu May 16 16:36:00 GMT 2002


>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);
}



More information about the Gcc-bugs mailing list