This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/11438] New: optmization bug with -fPIC
- From: "stas at fromru dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Jul 2003 22:58:23 -0000
- Subject: [Bug optimization/11438] New: optmization bug with -fPIC
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11438
Summary: optmization bug with -fPIC
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: critical
Priority: P1
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: stas at fromru dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
gcc version 3.3 release.
If compile following source with #gcc -o ptest -O3 -fPIC test.c
get Segmentation fault.
If remove static from PTEST declaration all is fine. Compiling with
#gcc -o ptest -O2 -fPIC test.c produce normal result.
[--cut--]
#include <stdio.h>
#include <stdlib.h>
typedef struct _test
{
int p1;
int p2;
char *p3;
} tests;
static tests *PTEST = NULL;
/* tests *PTEST = NULL; */
void init()
{
tests *ptest;
ptest = PTEST;
ptest = (tests*) malloc(sizeof(tests));
ptest->p1 = 1;
PTEST = ptest;
}
int p2()
{
tests *ptest;
ptest = PTEST;
return(ptest->p1);
}
main()
{
init();
printf("p1:%d\n", p2());
}
[--cut--]