Bug with -ftree-vrp?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux