public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/4950: gcc-3.0.2 unsigned char *pb++ produces double increment
@ 2001-11-21 1:56 Dennis Altrogge
0 siblings, 0 replies; only message in thread
From: Dennis Altrogge @ 2001-11-21 1:56 UTC (permalink / raw)
To: gcc-gnats; +Cc: Dennis Altrogge
>Number: 4950
>Category: c
>Synopsis: gcc-3.0.2 unsigned char *pb++ does double increment
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Nov 26 14:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Dennis Altrogge
>Release: 3.0.2
>Organization:
Nortel Networks
>Environment:
System: SunOS farside 5.6 Generic_105181-25 sun4m sparc SUNW,SPARCstation-20
Architecture: sun4
host: sparc-sun-solaris2.6
build: sparc-sun-solaris2.6
target: m68k-unknown-elf
configured with: ../gcc-3.0.2/configure --target=m68k-elf --with-newlib --prefix=/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf
>Description:
Compile the following C code with gcc-3.0.2 m68k-elf.
Use objdump to examine the .o file.
>How-To-Repeat:
############ screen output ##############
/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/bin/m68k-elf-gcc -c -g -O -funsigned-char -fno-builtin -Wall -v -save-temps \
-m5200 -Wa,-register-prefix-optional bug2.c
####### produced ################3
Reading specs from /engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/lib/gcc-lib/m68k-elf/3.0.2/specs
Configured with: ../gcc-3.0.2/configure --target=m68k-elf --with-newlib --prefix=/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf
Thread model: single
gcc version 3.0.2
/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/lib/gcc-lib/m68k-elf/3.0.2/cpp0 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=2 -Dmc68000 -D__embedded__ -D__mc68000__ -D__embedded__ -D__mc68000 -Asystem=embedded -Amachine=mc68000 -D__CHAR_UNSIGNED__ -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -Wall -Dmcf5200 -D__mcf5200__ -D__mcf5200 bug2.c bug2.i
GNU CPP version 3.0.2 (cpplib) (68k, MIT syntax)
ignoring nonexistent directory "/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/m68k-elf/sys-include"
#include "..." search starts here:
#include <...> search starts here:
/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/lib/gcc-lib/m68k-elf/3.0.2/include
/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/m68k-elf/include
End of search list.
/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/lib/gcc-lib/m68k-elf/3.0.2/cc1 -fpreprocessed bug2.i -quiet -dumpbase bug2.c -m5200 -g -O -Wall -version -funsigned-char -fno-builtin -o bug2.s
GNU CPP version 3.0.2 (cpplib) (68k, MIT syntax)
GNU C version 3.0.2 (m68k-elf)
compiled by GNU C version 2.95.2 19991024 (release).
/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/lib/gcc-lib/m68k-elf/3.0.2/../../../../m68k-elf/bin/as -m5200 -register-prefix-optional -o bug2.o bug2.s
/* ############## the bad C code gcc-3.0.2 (2.95.3 works)################## */
unsigned int er_F33BProgram(
unsigned int d_AdrLo,
unsigned int d_AdrHi,
void *pv_Data
)
{
unsigned char *pb_Data, b_Data;
pb_Data = pv_Data;
do
{
/*GNU3.0.2 with binutil2.11.2 produced moveb %a1@+,%d2 2X! for pb_Data++ */
b_Data = *pb_Data++ & *(volatile unsigned char*)d_AdrLo;
*(volatile unsigned char*)d_AdrLo = b_Data;
d_AdrLo += sizeof( unsigned char );
} while( d_AdrLo < d_AdrHi );
return 0;
}
/* ################### the bug2.i file ########################## */
#if 0
# 1 "bug2.c"
unsigned int er_F33BProgram(
unsigned int d_AdrLo,
unsigned int d_AdrHi,
void *pv_Data
)
{
unsigned char *pb_Data, b_Data;
pb_Data = pv_Data;
do
{
b_Data = *pb_Data++ & *(volatile unsigned char*)d_AdrLo;
*(volatile unsigned char*)d_AdrLo = b_Data;
d_AdrLo += sizeof( unsigned char );
} while( d_AdrLo < d_AdrHi );
return 0;
}
#endif
/* #################### objdump of bug2.o ############################ */
#if 0
/* produced this */
bug2.o: file format elf32-m68k
Disassembly of section .text:
00000000 <er_F33BProgram>:
0: 4e56 0000 linkw %fp,#0
4: 2f02 movel %d2,%sp@-
6: 206e 0008 moveal %fp@(8),%a0
a: 222e 000c movel %fp@(12),%d1
e: 226e 0010 moveal %fp@(16),%a1
12: 1010 moveb %a0@,%d0
/* ######### here is the bug: note BYTE *pb_Data++ produces 2X incs */
14: 1419 moveb %a1@+,%d2
16: 1419 moveb %a1@+,%d2
18: c082 andl %d2,%d0
/* gcc-2.95.3 optimized the next 2 instructions to: 10c0 moveb %d0,%a0@+ */
1a: 1080 moveb %d0,%a0@
1c: 5288 addql #1,%a0
1e: b288 cmpl %a0,%d1
20: 62f0 bhis 12 <er_F33BProgram+0x12>
22: 4280 clrl %d0
24: 241f movel %sp@+,%d2
26: 4e5e unlk %fp
28: 4e75 rts
...
#endif
>Fix:
No known fix.
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-11-26 22:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-21 1:56 c/4950: gcc-3.0.2 unsigned char *pb++ produces double increment Dennis Altrogge
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).