This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/13984] New: Bad code generated with -O0
- From: "klawson at ad-holdings dot co dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Feb 2004 17:38:28 -0000
- Subject: [Bug c/13984] New: Bad code generated with -O0
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code was generated by sh-elf-gcc. The space variable (a long) is
taken from @(0,r3) and stored in r1. The len variable is taken from @(4.r3) and
stored in r3. A subtract operation is then performed, and r3 is used to find
where to store the result. This is bad because r3 was used as temporary storage
for the subtract operation and no longer contains a reference to memory. The
final mov.l instruction causes a fault as it is storing to a misaligned
(nonsense) address.
576 space -= len;
- 0x8c0bb984 <cyg_sosend+2148>: mov #64,r3
- 0x8c0bb986 <cyg_sosend+2150>: add r14,r3
- 0x8c0bb988 <cyg_sosend+2152>: mov #64,r3
- 0x8c0bb98a <cyg_sosend+2154>: add r14,r3
- 0x8c0bb98c <cyg_sosend+2156>: mov.l @(0,r3),r1
- 0x8c0bb98e <cyg_sosend+2158>: mov.l @(4,r3),r3
- 0x8c0bb990 <cyg_sosend+2160>: sub r3,r1
- 0x8c0bb992 <cyg_sosend+2162>: mov.l r1,@(0,r3)
The following CFLAGS are used:
-mb -m3 -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef
-Woverloaded-virtual -ggdb -O0 -ffunction-sections -fdata-sections -fno-rtti
-fno-exceptions -fvtable-gc -finit-priority
Using optimisation level 1, the code is generated as:
576 space -= len;
- 0x8c0a6080 <cyg_sosend+1280>: sub r8,r11
--
Summary: Bad code generated with -O0
Product: gcc
Version: 3.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: klawson at ad-holdings dot co dot uk
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-cygwin
GCC target triplet: sh-elf-gcc
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13984