This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/9902: optimization level -O2/3 doesn't work correctly.
- From: gennadi dot f at corigin dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 2 Mar 2003 16:23:37 -0000
- Subject: c/9902: optimization level -O2/3 doesn't work correctly.
- Reply-to: gennadi dot f at corigin dot com
>Number: 9902
>Category: c
>Synopsis: optimization level -O2/3 doesn't work correctly.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 02 16:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: gennadi dot f at corigin dot com
>Release: 3.2.2
>Organization:
>Environment:
sunOS 2.8 sparc
>Description:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
char *page,*p;
page=calloc(1,4);
page+=4;
p=page;
if (page) { // if we change "page" here to "1", the result will be correct
*((char **)page-1)=page; // save the address in its previous 4 bytes.
(*((char ***)page-1))++; // add 4 to the saved address.
}
page=*((char **)page-1); //"page" should be assigned to the new value.
printf("page=%08X p=%08X\n",page,p); // with the optimization level -O2/3, the value of page i
s not changed.
return 0;
}
>How-To-Repeat:
compile with and without O3/O2 options.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: