------- 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