Bug 16372 - [4.0 Regression] Wrong code for enums
Summary: [4.0 Regression] Wrong code for enums
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 3.4.1
: P3 critical
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
: 15354 15776 16791 25014 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-07-05 18:56 UTC by Tobias Schuele
Modified: 2005-11-25 20:23 UTC (History)
6 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work: 3.4.2 3.3.3
Known to fail: 4.0.0
Last reconfirmed: 2004-07-05 21:16:17


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Schuele 2004-07-05 18:56:04 UTC
Hi, 
 
there still seems to be a problem with enums in GCC 3.4.1 (see bug #15069). 
When you compile the follwing snippet with -O0, everthing works well. However, 
with -O1, the output is "234" which is wrong. Sorry, if this is a duplicate 
bug report, but I assumed it would be fixed in GCC 3.4.1. Thanks for your 
help. 
 
Regards, 
Tobias 
 
 
#include <iostream> 
 
enum number {ZERO, ONE, TWO, THREE, FOUR, FIVE}; 
 
int main() { 
  number n = FIVE; 
 
  if((n == ONE) || (n == TWO) || (n == THREE)) { 
    std::cout << "234" << std::endl; 
  } 
}
Comment 1 Tobias Schuele 2004-07-05 19:03:33 UTC
Of course, the output should be "123", but that doesn't make a difference... 
Comment 2 Andrew Pinski 2004-07-05 21:16:17 UTC
Confirmed, I must have closed one bug as a dup of that bug thinking they were the same problem when 
in fact this comes from the shorting part of fold.
Comment 4 Andrew Pinski 2004-07-27 23:31:50 UTC
*** Bug 16791 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2004-07-27 23:32:25 UTC
*** Bug 15776 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2004-07-27 23:33:35 UTC
*** Bug 15354 has been marked as a duplicate of this bug. ***
Comment 7 Wolfgang Bangerth 2004-07-28 01:39:48 UTC
Just to confirm the present state: it works with 3.4.1, but doesn't 
with mainline. 
 
Jakub, what was the reason to apply this only to the 3.4 branch, and 
not to mainline? 
 
W. 
Comment 8 Jakub Jelinek 2004-07-29 18:40:10 UTC
The reason is rth's objection against applying this to mainline:
http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00978.html
Comment 11 Andrew Pinski 2004-08-25 20:58:48 UTC
Fixed.
Comment 12 Andrew Pinski 2005-11-25 20:23:01 UTC
*** Bug 25014 has been marked as a duplicate of this bug. ***