public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexey Neyman <stilor@att.net>
To: gcc-help@gcc.gnu.org
Subject: Bug with -ftree-vrp?
Date: Sun, 03 Aug 2008 00:05:00 -0000	[thread overview]
Message-ID: <200808021704.38246.stilor@att.net> (raw)

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 <stdio.h>

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.

             reply	other threads:[~2008-08-03  0:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-03  0:05 Alexey Neyman [this message]
2008-08-03  0:26 ` Brian Dessent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200808021704.38246.stilor@att.net \
    --to=stilor@att.net \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).