Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 15776
Product:  
Component:  
Status: RESOLVED
Resolution: DUPLICATE of bug 16372
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Michael Gollin <gollin@informatik.hu-berlin.de>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 15776 depends on: Show dependency tree
Show dependency graph
Bug 15776 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2004-06-02 13:15
The following program doesn't run properly when compiled with -O

#include <stdio.h>
 
enum OptionStateEnum
{
  SLEEPING,
  ACTIVE,
  INTENDED,
  DESIRED,
  EXECUTED,
  ABORTED
};
 
int main()
{
  OptionStateEnum l[2] = { EXECUTED, ACTIVE };
 
  OptionStateEnum state;
  for ( int i = 0; i < 2; ++i ) {
    state = l[i];
    printf( "state = %d\n", state );
    if ( ( state == DESIRED ) ||
         ( state == INTENDED ) ||
         ( state == ACTIVE ) ) {
      printf( "break state = %d\n", state );
      break;
    }
  }

  return 0;
}


The program was compiled using the following command:
gcc -O -g0 optimize-enum.cpp -o optimize-enum.exe

Resulting in the following output:
state = 4
break state = 4


When compiled with -O0 the output is as expected:
state = 4
state = 1
break state = 1

The problem also vanishes when checking for 4 or only 2 enums in the
if-statement. Or when assigning explicit values to the enums (0, 2, 4, 8, 16,
32, 64).

Cheers,
Michael Gollin

------- Comment #1 From Andrew Pinski 2004-06-02 13:18 -------
This is a dup of bug 15069 which is fixed for 3.4.1.

*** This bug has been marked as a duplicate of 15069 ***

------- Comment #2 From Andrew Pinski 2004-07-27 23:32 -------
Reopen as I marked it as a wrong bug as a dup of.

------- Comment #3 From Andrew Pinski 2004-07-27 23:32 -------

*** This bug has been marked as a duplicate of 16372 ***

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug