public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/15354] New: wrong code regression on enum test
@ 2004-05-09 20:35 senor_fjord at yahoo dot com
2004-05-09 20:46 ` [Bug optimization/15354] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: senor_fjord at yahoo dot com @ 2004-05-09 20:35 UTC (permalink / raw)
To: gcc-bugs
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
--
Summary: wrong code regression on enum test
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: senor_fjord at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15354
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug optimization/15354] wrong code regression on enum test
2004-05-09 20:35 [Bug optimization/15354] New: wrong code regression on enum test senor_fjord at yahoo dot com
@ 2004-05-09 20:46 ` pinskia at gcc dot gnu dot org
2004-07-27 23:33 ` [Bug rtl-optimization/15354] " pinskia at gcc dot gnu dot org
2004-07-27 23:33 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-09 20:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 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 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15354
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug rtl-optimization/15354] wrong code regression on enum test
2004-05-09 20:35 [Bug optimization/15354] New: wrong code regression on enum test senor_fjord at yahoo dot com
2004-05-09 20:46 ` [Bug optimization/15354] " pinskia at gcc dot gnu dot org
@ 2004-07-27 23:33 ` pinskia at gcc dot gnu dot org
2004-07-27 23:33 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-27 23:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-07-27 23:32 -------
Reopening to mark as a dup of a differnet bug.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|DUPLICATE |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15354
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug rtl-optimization/15354] wrong code regression on enum test
2004-05-09 20:35 [Bug optimization/15354] New: wrong code regression on enum test senor_fjord at yahoo dot com
2004-05-09 20:46 ` [Bug optimization/15354] " pinskia at gcc dot gnu dot org
2004-07-27 23:33 ` [Bug rtl-optimization/15354] " pinskia at gcc dot gnu dot org
@ 2004-07-27 23:33 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-27 23:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-07-27 23:33 -------
*** This bug has been marked as a duplicate of 16372 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15354
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-07-27 23:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-09 20:35 [Bug optimization/15354] New: wrong code regression on enum test senor_fjord at yahoo dot com
2004-05-09 20:46 ` [Bug optimization/15354] " pinskia at gcc dot gnu dot org
2004-07-27 23:33 ` [Bug rtl-optimization/15354] " pinskia at gcc dot gnu dot org
2004-07-27 23:33 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).