Bug 55227

Summary: gcc miscompiles test app, embedded asm
Product: [Retired] Red Hat Linux Reporter: Manfred Spraul <manfred>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-02 00:45:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
test app none

Description Manfred Spraul 2001-10-27 19:04:33 UTC
Description of Problem:
gcc miscompiles code with -O2, correct with -O0

Version-Release number of selected component (if applicable):
gcc-2.96-98

How Reproducible:
compile the attachment
options:
	gcc -O2 -fomit-frame-pointer -o bad badgcc.cpp
	gcc -O0 -fomit-frame-pointer -o good badgcc.cpp
run it.

Actual Results:
got tsd 2152509265989 at esp=bffffb20h for time=bffffb50h.
got tsd 2152539497047 at esp=bffffb20h for time=bffffb48h.
needed 30231058 cycles (3.023106/call).
got tsd 2154240734828 at esp=bffffb20h for time=bffffb40h.
					^^^^^^^
got tsd 2154270773195 at esp=bffffb20h for time=bffffb48h.

must be b50, not b40.

Expected Results:
got tsd 2143396909839 at esp=bffffb00h for time=bffffb60h.
got tsd 2143484049795 at esp=bffffb00h for time=bffffb58h.
needed 87139956 cycles (8.713996/call).
got tsd 2145186785406 at esp=bffffb00h for time=bffffb60h.
got tsd 2145273718039 at esp=bffffb00h for time=bffffb58h.
needed 86932633 cycles (8.693263/call).


Additional Information:

Comment 1 Manfred Spraul 2001-10-27 19:06:58 UTC
Created attachment 35262 [details]
test app

Comment 2 Jakub Jelinek 2001-10-29 10:21:17 UTC
gcc 3.0 and gcc 3.1 behave similarly. gcc handles *FRAME_POINTER registers
specially apparently, even with -fomit-frame-pointer, when needed.

Comment 3 Richard Henderson 2004-10-02 00:45:18 UTC
This is dodgy code at best, but gcc 3.4 will at least give 

z.c:58: error: bp cannot be used in asm here

instead of generating code that crashes.