http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50115

             Bug #: 50115
           Summary: Integer test optimised away at -O2 by the VRP
    Classification: Unclassified
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bal...@szentedwg.ro


Created attachment 25047
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25047
Preprocessed file with Suse's GCC 4.5.1

The value == numeric_limits<int>::min() test will be always considered false in
the attached preprocessed files using -O2 with G++ v4.5 and up.

Steps to reproduce:
$ g++ -o vrp-bug vrp-bug.cpp -O2
$ ./vrp-bug
$ echo $?

Expected result:
0

Actual result:
1

G++ versions affected:
4.5 and up (4.4.5 for example is working well).

Additional info:
The compiler considers for some reason "value" not equal with
numeric_limits<int>::min(), and simply generates only the else branch of the
"if".
The -fno-tree-vrp fixes the problem, it seems VRP takes wrong decision at
compile time.

See the attached preprocessed source codes with the corresponding G++ version
logs.

Reply via email to