https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66088
Bug ID: 66088 Summary: -Wunused-but-set-variable does not regard static variable access in local scope Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: vshebordaev at mail dot ru Target Milestone: --- As of gcc 4.9.2, I get faulty -Wunused-but-set-variable warning (and broken build with -Wall) in this case 1 struct test { 2 int t; 3 }; 4 5 int main(int argc, const char *argv[]) 6 { 7 static struct test t = { 0 }; 8 struct test v = { 1 }; 9 10 t = v; 11 12 return 0; 13 } The warning disappears when t is referenced by its address, i.e. when line 10 changed to 10 *(&t) = v; which is considered as a usage but looks ridiculously.