This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/14669] New: Wrong code with -O for enum values expression E4 <= t && t <= E6


Wrong code with -O for enum values expression E4 <= t && t <= E6

Current mainline CVS g++ (gcc version 3.5.0 20040320) and
current 3.4      CVS g++ (gcc version 3.4.0 20040321)
produce wrong code for program with optimization (g++ -O Test.cc command line):

---8X---------------------------
#include<iostream>

enum Enum { EE =-1, E0 = 0, E1, E2, E3, E4, E5, E6, E7 };

int main() {
  Enum t = E2; 

  bool f = E4 <= t && t <= E6;

  std::cout << "Expr1: False = " << (f  ? "True" : "False") << std::endl;

  bool f1 = E4 <= t;
  bool f2 = t  <= E6;
  bool ff = f1 && f2;

  std::cout << "Expr2: False = " << (ff ? "True" : "False") << std::endl;

  return 0;
}
--X8-----------------------
Program compiled with optimization (g++ -O Test.cc) output:
Expr1: False = True
Expr2: False = False

Program compiled without optimization (g++ Test.cc) output (correct):
Expr1: False = False
Expr2: False = False

gcc version 3.2.2 [FreeBSD] 20030205 (release) doesn't have this problem.

Initial for testcase source code have been compiled and work without this 
problem at some days old version of GCC mainline.

-- 
           Summary: Wrong code with -O for enum values expression E4 <= t &&
                    t <= E6
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wanderer at rsu dot ru
                CC: gcc-bugs at gcc dot gnu dot org,mark at codesourcery dot
                    com
 GCC build triplet: i386-unknown-freebsd5.1
  GCC host triplet: i386-unknown-freebsd5.1
GCC target triplet: i386-unknown-freebsd5.1


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]