[Bug c/48782] New: unused-but-set static variables are not optimized out

flameeyes at gentoo dot org gcc-bugzilla@gcc.gnu.org
Tue Apr 26 23:38:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48782

           Summary: unused-but-set static variables are not optimized out
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: flameeyes@gentoo.org


int main() {
  static unsigned char done = 0;

  done = 1;
  return 1;
}

The done variable is properly reported as unused-but-set by gcc but both the
"done = 1" store and the memory area itself is kept in the produced code up to
-O3.



More information about the Gcc-bugs mailing list