public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/8376: GCC always keeps static const objects
@ 2002-10-31 18:55 rth
0 siblings, 0 replies; 2+ messages in thread
From: rth @ 2002-10-31 18:55 UTC (permalink / raw)
To: aloeff, gcc-bugs, gcc-prs, nobody
Synopsis: GCC always keeps static const objects
State-Changed-From-To: open->closed
State-Changed-By: rth
State-Changed-When: Thu Oct 31 18:55:34 2002
State-Changed-Why:
Not a bug. You are confusing C and C++ semantics.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8376
^ permalink raw reply [flat|nested] 2+ messages in thread
* optimization/8376: GCC always keeps static const objects
@ 2002-10-28 2:26 aloeff
0 siblings, 0 replies; 2+ messages in thread
From: aloeff @ 2002-10-28 2:26 UTC (permalink / raw)
To: gcc-gnats
>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=
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-11-01 2:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-31 18:55 optimization/8376: GCC always keeps static const objects rth
-- strict thread matches above, loose matches on Subject: below --
2002-10-28 2:26 aloeff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).