https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69981
--- Comment #5 from David L. <equinox-gccbugs at diac24 dot net> --- (In reply to David L. from comment #4) > Poking around a bit, in wrapup_global_declaration_2() in gcc/toplev.c, the > check for > else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl) > && (optimize || !flag_keep_static_consts > || DECL_ARTIFICIAL (decl))) > is never hit because the earlier > else if (node && node->definition) > > needed = false; > is taken (on both -O0 or -O1). > > Thus, the value of flag_keep_static_consts is irrelevant (and this is the > only place in the code where it's used...) If I put a "static const int intvalnoinit;" into my test source, -fno-keep-static-consts does actually have an effect on that. It seems a little counterintuitive to me though that static consts only get removed if they have no initialiser...