[Bug c/38630] New: Is this a bug in gcc 2.95.3 ( m/c SunOS 5.7 sun4u sparc SUNW,Ultra-80 )
soumendus at rediffmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Dec 26 15:22:00 GMT 2008
Hi,
This seems to be a bug in the default ÂO0 optimization level. With ÂO1 , -O2
and ÂO3 it works fine.
I have seen it many times that it generates perfect code with ÂO1 , -O2 and ÂO3
but if I change to ÂO0
things donÂt work.
The following is the issue.
The following function func( ) is being called from another file main.c
// file main.c
#include Âtest.hÂ
// static variable declarations.
main( )
{
.//variable declarations
.
.
func();
func1();
}
//file test.c
int func( )
{
int var1 = MAX_BIN_SIZE;
int var2 = MAX_BIN_SIZE;
.
.
.
.
}
In the file test.c the above is declared. MAX_BIN_SIZE is defined to 256 in the
header file test.h
The value of var2 , even after the assignment to MAX_BIN_SIZE, still prints 0.
But the var1 is properly defined i.e 256.
The above function func( ) in test.c , I am making a static library (.a ) and
linking with my main to get the executable.
There are other static libraries also which I am linking with this main.
If I change the optimizer level to ÂO1 or ÂO2 or ÂO3, everything seems to be
fine. It only happens with ÂO0.
Thanks
Soumendu
--
Summary: Is this a bug in gcc 2.95.3 ( m/c SunOS 5.7 sun4u sparc
SUNW,Ultra-80 )
Product: gcc
Version: 2.95.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: soumendus at rediffmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38630
More information about the Gcc-bugs
mailing list