From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1143 invoked by alias); 26 Sep 2009 18:02:03 -0000 Received: (qmail 28434 invoked by uid 48); 26 Sep 2009 18:01:50 -0000 Date: Sat, 26 Sep 2009 18:02:00 -0000 Subject: [Bug c/41477] New: gcc does not optimize a case that it should to make __builtin_object_size() more useful X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "arjan at linux dot intel dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-09/txt/msg02428.txt.bz2 (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