This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/20319] -fkeep-static-consts with -O asserted doesn't keep consts
- From: "gary at intrepid dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Mar 2005 21:54:39 -0000
- Subject: [Bug c/20319] -fkeep-static-consts with -O asserted doesn't keep consts
- References: <20050304170516.20319.gary@intrepid.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From gary at intrepid dot com 2005-03-04 21:54 -------
Here is some detail on my proposed change in behavior:
1) Change the default setting to -fno-keep-static-consts:
/* Nonzero means that we should emit static const variables
regardless of whether or not optimization is turned on. */
int flag_keep_static_consts = 0;
2) have flag_keep_static_consts affect only the behavior of the
compiler when 'optimize' is asserted:
Change the logic in wrapup_global_declarations (toplev.c) to read:
else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
&& (optimize && !flag_keep_static_consts)
|| DECL_ARTIFICIAL (decl)))
needed = 0;
This change would imply that:
1) -fkeep-static-consts and -fno-keep-static-consts will have no effect
at -O0. Presently, -fno-keep-static-consts would eliminate the unreferenced
static const variable if it isn't referenced. This would no longer be
the case. At -O0, the compiler would always leave unrefereced static
consts alone.
2) If optimization is asserted (ie, -O1 and above), then always eliminate
static const's that aren't referenced, unless -fkeep-static-consts is
asserted.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20319