From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13647 invoked by alias); 3 Aug 2008 00:05:21 -0000 Received: (qmail 13634 invoked by uid 22791); 3 Aug 2008 00:05:19 -0000 X-Spam-Check-By: sourceware.org Received: from smtp121.sbc.mail.sp1.yahoo.com (HELO smtp121.sbc.mail.sp1.yahoo.com) (69.147.64.94) by sourceware.org (qpsmtpd/0.31) with SMTP; Sun, 03 Aug 2008 00:04:41 +0000 Received: (qmail 34448 invoked from network); 3 Aug 2008 00:04:39 -0000 Received: from unknown (HELO dv9000t) (stilor@att.net@69.107.75.182 with plain) by smtp121.sbc.mail.sp1.yahoo.com with SMTP; 3 Aug 2008 00:04:39 -0000 X-YMail-OSG: WC4w40YVM1mi3hsOMt0LS.t9373.Jn4wdDe_62ZBcaRgSWSBjAwTRz4.LyABLI4Rx.5_g5JGHajRf_0ZJCLO7xOqX0xUkSP8mYj13vTFQg-- X-Yahoo-Newman-Property: ymail-3 From: Alexey Neyman To: gcc-help@gcc.gnu.org Subject: Bug with -ftree-vrp? Date: Sun, 03 Aug 2008 00:05:00 -0000 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200808021704.38246.stilor@att.net> Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00012.txt.bz2 Howdy, I stumbled over this misbehavior while debugging some problem in Wireshark. The problem has been reduced to the test case below (a simplified snippet from the time_secs_to_str_buf() function in Wireshark): <<<<< #include void foo(int v) { if (v < 0) { v = -v; } if (v < 0) { fprintf(stderr, "bad number\n"); return; } fprintf(stderr, "[%d]\n", v); } int main(void) { foo(0x80000000); return 0; } <<<<<< The problem is that with -O2, the second conditional gets optimized away. However, such optimization results in a misbehavior for the minimum number representable in 32 bits, 0x80000000. The option which triggers this optimization is -ftree-vrp. I would consider this a bug in VRP, since (judging by the description of the -ftree-vrp option), this option is only supposed to eliminate equivalent ranges. Regards, Alexey. Best regards, Alexey Neyman.