Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 15354
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: senor_fjord@yahoo.com
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 15354 depends on: Show dependency tree
Show dependency graph
Bug 15354 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2004-05-09 20:35
The following code compiles fine on g++ 3.3.3 and 3.2.2, but does not on 3.4.0
or 3.4.1 release 
20040502.  I'm not sure if this is related to bug 15069 or not.  The code
example is below.  When 
compiled with 3.4, it executes the print statement.  This bug only occurs when
optimization (-O1, -O2, 
or -O3) is enabled.

int printf(char *, ...);

enum my_enum_e {
  zero      = 0,
  one       = 1,
  two       = 2,
  three     = 3,
  four      = 4,
  five      = 5,
  six       = 6,
  seven     = 7,
  eight     = 8,
  nine      = 9,
  ten       = 10,
  eleven    = 11,
  twelve    = 12,
  thirteen  = 13,
  fourteen  = 14,
  fifteen   = 15,
  sixteen   = 16,
  seventeen = 17,
  eighteen  = 18,
  nineteen  = 19,
  numbers   = 20
};

my_enum_e ret_nineteen() {
  return nineteen;
}


int main() {
  my_enum_e enm = ret_nineteen();

  if (enm == one      || enm == two      || enm == three   ||
      enm == four     || enm == five     || enm == six     ||
      enm == seven    || enm == eight    || enm == nine    ||
      enm == ten      || enm == eleven   || enm == twelve  ||
      enm == thirteen || enm == fourteen || enm == fifteen ||
      enm == sixteen)
    printf("shouldn't print");

  return 0;
}


The generated assembly is the following.  The test at EIP 804844f isn't correct
if I'm reading the code 
right.

08048434 <ret_nineteen()>:
 8048434:       55                      push   %ebp
 8048435:       89 e5                   mov    %esp,%ebp
 8048437:       b8 13 00 00 00          mov    $0x13,%eax
 804843c:       5d                      pop    %ebp
 804843d:       c3                      ret    

0804843e <main>:
 804843e:       55                      push   %ebp
 804843f:       89 e5                   mov    %esp,%ebp
 8048441:       83 ec 08                sub    $0x8,%esp
 8048444:       83 e4 f0                and    $0xfffffff0,%esp
 8048447:       83 ec 10                sub    $0x10,%esp
 804844a:       e8 e5 ff ff ff          call   8048434 <ret_nineteen()>
 804844f:       85 c0                   test   %eax,%eax
 8048451:       74 0c                   je     804845f <main+0x21>
 8048453:       c7 04 24 48 85 04 08    movl   $0x8048548,(%esp,1)
 804845a:       e8 f9 fe ff ff          call   8048358 <_init+0x38>
 804845f:       b8 00 00 00 00          mov    $0x0,%eax
 8048464:       c9                      leave  
 8048465:       c3                      ret    
 8048466:       90                      nop    
 8048467:       90                      nop

------- Comment #1 From Andrew Pinski 2004-05-09 20:46 -------
This is a dup of bug 15069 as fold is what is cause to create the bad code and
it is happening in the 
same spot.

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

------- Comment #2 From Andrew Pinski 2004-07-27 23:32 -------
Reopening to mark as a dup of a differnet bug.

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

*** 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