(see attached testcases; testcase.c shows the problem, testcase2.c shows that reorging the code works around it)
it appears that gcc does not realize that after if (variable < 1 || variable > 10) return -1; the "variable" is in the range [1..10], likely because the execution of the second check is optional due to the ||. in a typical __builtin_object_size() scenario, like if (__builtin_object_size(foo) < variable) some_error(); where foo is 10 bytes in size, this means the check does not get optimized out. -- Summary: gcc does not optimize a case that it should to make __builtin_object_size() more useful Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: arjan at linux dot intel dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41477