Bug 16372 - [4.0 Regression] Wrong code for enums
Summary: [4.0 Regression] Wrong code for enums
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
Keywords: wrong-code
: 15354 15776 16791 25014 (view as bug list)
Depends on:
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
Known to work: 3.4.2 3.3.3
Known to fail: 4.0.0
Last reconfirmed: 2004-07-05 21:16:17


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
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 
#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? 
Comment 8 Jakub Jelinek 2004-07-29 18:40:10 UTC
The reason is rth's objection against applying this to mainline:
Comment 11 Andrew Pinski 2004-08-25 20:58:48 UTC
Comment 12 Andrew Pinski 2005-11-25 20:23:01 UTC
*** Bug 25014 has been marked as a duplicate of this bug. ***