Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Tom Tkacik
Mon, 03 Oct 1988 14:19
gcc-1.28 generates wrong code for unsigned short to int
Author: Tom Tkacik
Date: Mon, 03 Oct 1988 14:19
Date: Mon, 03 Oct 1988 14:19
97 lines
2577 bytes
2577 bytes
PROBLEM: Gcc-1.28, (when not optimizing), produces
incorrect code for moves from an unsigned short
to either an int or an unsigned int.
With the optimizer on, the correct code is emitted.
(Does this happen on all versions, or only mine?)
Tom Tkacik
{umix!mcf, uunet!edsews}!rphroy!tetnix!tet
SYSTEM: AT&T UnixPC UNIX: SYSV.? (ver 3.5)
CONFIGURATION FILES: standard for the UnixPC
tm.h ----> tm-3b1.h
md ----> m68k.md
aux-output.c ----> output-m68k.c
COMMAND: gcc -v -S -gg bug.c
The -gg option is for aiding in reading the output file.
A program compiled with -gg cannot be assembled on the UnixPC.
VERSION:
gcc version 1.28
/usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68k -Dunix -Dunixpc bug.c /tmp/cca03586.cpp
GNU CPP version 1.28
/usr/local/lib/gcc-cc1 /tmp/cca03586.cpp -quiet -dumpbase bug.c -version -symout /tmp/cca03586.sym -o bug.s
GNU C version 1.28 (68k, SGS/AT&T unixpc syntax) compiled by GNU C version 1.28.
---------------------------------------------------------------
/* bug.c -- gcc makes two errors in this code */
unsigned int ui;
int i;
unsigned short us;
short s;
f()
{
i = s;
i = us; /* gcc gets this wrong */
ui = s;
ui = us; /* this also */
}
---------------------------------------------------------------
file "bug.c"
.text 0
.gdbbeg 0
.gdbbeg 1
Ltext: .stabs "bug.c",100,0,0,Ltext
.data 0
Ldata:
lcomm Lbss,0
.gdbsym Ldata,52
.gdbsym Lbss,56
text
even
global f
f:
.gdbbeg 2
.gdbline 0,9
link.w %a6,&0
mov.l %d2,-(%sp)
.gdbline 0,10
mov.w s,%a0 <---- short to int is correct
mov.l %a0,i
.gdbline 0,11
mov.w us,%d2 <---- unsigned short to int is wrong
clr.l i
mov.l i,%d0
mov.w %d2,%d0
mov.l %d0,%d0
.gdbline 0,12
mov.w s,%a0 <---- short to unsigned is correct
mov.l %a0,ui
.gdbline 0,13
mov.w us,%d2 <---- unsigned short to unsigned is wrong
clr.l ui
mov.l ui,%d0
mov.w %d2,%d0
mov.l %d0,%d0
.gdbline 0,14
L%1:
.gdbend 2
mov.l -4(%a6),%d2
unlk %a6
rts
.gdbblock 2,1188
comm s,2
comm us,2
comm i,4
comm ui,4
.text 0
.gdbend 0
.gdbblock 0,1328
.gdbend 1
.gdbblock 1,1864
.gdblinetab 0,2092
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads