public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Bug with -ftree-vrp?
@ 2008-08-03  0:05 Alexey Neyman
  2008-08-03  0:26 ` Brian Dessent
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Neyman @ 2008-08-03  0:05 UTC (permalink / raw)
  To: gcc-help

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-03  0:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-03  0:05 Bug with -ftree-vrp? Alexey Neyman
2008-08-03  0:26 ` Brian Dessent

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).