This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/12342] New: [tree-ssa] staticvariables in static functions are incorrectly "optimized" away
- From: "gerald at pfeifer dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Sep 2003 18:51:01 -0000
- Subject: [Bug middle-end/12342] New: [tree-ssa] staticvariables in static functions are incorrectly "optimized" away
- 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=12342
Summary: [tree-ssa] staticvariables in static functions are
incorrectly "optimized" away
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gerald at pfeifer dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i386-unknown-freebsd4.8
Consider the following example x.c:
static bool checkWC(bool newstate) {
static bool state=false;
if (state==false)
state=newstate;
return state==newstate;
}
int main() {
return checkWC(false);
}
If compiled with -O3, gcc incorrectly "optimizes" away the state variable in
the function.
% gccvs -O3 x.c
/var/tmp//ccVmxe3H.o: In function `main':
/var/tmp//ccVmxe3H.o(.text+0x7): undefined reference to `checkWC(bool)::state'
/var/tmp//ccVmxe3H.o(.text+0x14): undefined reference to`checkWC(bool)::state'
collect2: ld returned 1 exit status