// David Li Gcc is solid in performing dead function elimination and dead variable elimination for statics. It handles cases when a dead variable is referenced (via initializer) by other dead variables pretty well. The missing opportunities noticed is that it fails to discover dead stores to static variables where are never used -- thus missing the dead variable elimination ...
Example 1: static int s; static int* p =&s; int foo() { p = 0; // Dead, not eliminated } Example 2: static int g = 10; static int* gp = &g; int foo() { gp = 0; // Dead store return g; // should be const proped } -- Summary: Missing dead store elimination for statics Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: xinliangli at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35361