This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/8376: GCC always keeps static const objects


>Number:         8376
>Category:       optimization
>Synopsis:       GCC always keeps static const objects
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 28 02:26:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Andreas Loeffler
>Release:        3.2 (3.1, 2.96)
>Organization:
>Environment:
red hat 7.3
Reading specs from /opt/fsp/i586-pc-linux-gnu/local/lib/gcc-lib/powerpc-linux/3.2/specs
Configured with: ../configure --host=i586-pc-linux-gnu --target=powerpc-linux --prefix=/opt/fsp/i586-pc-linux-gnu/local --enable-shared --enable-languages=c,c++,f77 --with-headers=/opt/fsp/powerpc-linux/include --with-libs=/opt/fsp/powerpc-linux/lib --with-cpu=403 --without-fp
Thread model: posix
gcc version 3.2
>Description:
GCC doesn't seem to eliminate static const objects at all.

I use the following code for testing:


> --------- "x.c" --------<
 
static const int blah=27;
static const int yunk=93;
 
int foo(int num)
{
    return blah*num;
}
 
int bar(int num)
{
    return blah+num+foo(blah+num);
}
> --------- end "x.c" ----<


In this code, 'blah' should not be referenced, once optimization
took place.
'yunk' is never used.  Still, GCC keeps them both in the output
file.

To verify this I tried the following command lines with GCC
3.2 

powerpc-linux-gcc -O -c x.c
powerpc-linux-gcc -Os -c x.c
powerpc-linux-gcc -O3 -c x.c
powerpc-linux-gcc -fno-keep-static-consts -c x.c

In all cases, when I examine the output file with powerpc-linux-nm,
I see the symbols 'blah' and 'yunk'.
I also tried the gcc 2.96 on RedHat, with the same result.
>How-To-Repeat:
powerpc-linux-gcc -Os -c x.c
powerpc-linux-gcc -O3 -c x.c
powerpc-linux-gcc -fno-keep-static-consts -c x.c
>Fix:
?
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="x.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="x.c"

c3RhdGljIGNvbnN0IGludCBibGFoPTI3OwpzdGF0aWMgY29uc3QgaW50IHl1bms9OTM7CiAKaW50
IGZvbyhpbnQgbnVtKQp7CiAgICByZXR1cm4gYmxhaCpudW07Cn0KIAppbnQgYmFyKGludCBudW0p
CnsKICAgIHJldHVybiBibGFoK251bStmb28oYmxhaCtudW0pOwp9Cgo=


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]