[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