gcc bug. generate assembly store 8 byte to 4 byte aligned address.
Akinori Furuta
furuta@mei9.advantest.co.jp
Tue Dec 7 03:23:00 GMT 1999
Hi, the GCC team.
I found GCC bug. That is appered in following condition.
OS: Solaris 2.5.1
Machine: SUN Ultra 1 model 140
uname shows: % uname -a
SunOS toolbox 5.5.1 Generic_103640-22 sun4u sparc
SUNW,Ultra-1
gcc shows: % gcc --version
2.8.1
Source code characteristic:
1. Call to a variable argument function.
2. Many arguments (in double type, more than about 512
arguments ) are passed to a variable argument function.
3. Both integer (4 byte) and double (8 byte) aguments appere
in variable arguments.
4. Odd number of consecutive integer (4 byte) aguments appere
in variable arguments.
Example: ( ... i, ... i,i,i, ... i,i,i,i,i, ...)
The source code List.1 satisfies these four condition described in
'Source code characteristic'.
Compiling the source, GCC generate wrong assembly output that attempt to
store 8 byte register (4 byte register pair) to 4 byte aligned address.
Figure.1 shows compiling the List.1 and running the a.out. The "a.out"
raise bus error exception.
I analyzed assembly output of the List.1, and found wrong assembly output
such as follows.
main:
...
...
st %o4,[%sp+4084] ;store 4 byte to 4 byte aligned address.
st %o5,[%sp+4088] ;store 4 byte to 4 byte aligned address.
st %o4,[%sp+4092] ;store 4 byte to 4 byte aligned address.
add %sp,0x4,%sp
st %o5,[%sp+4092] ;store 4 byte to 4 byte aligned address.
add %sp,-0x4,%sp
sethi %hi(4100),%o0
or %o0,%lo(4100),%o0
std %o4,[%sp+%o0] ;store 8 byte to 4 byte aligned address!!
...
...
call fvaa,0
...
Figure. 1 Compiling the List.1 and running the a.out.
% gcc -v --save-temps -O vaa.c
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.8.1/specs
gcc version 2.8.1
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.8.1/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR_
_=8 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D_
_sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__OPTIMIZE__ -D__GCC_NEW_VARARGS__ -Acpu(spar
c) -Amachine(sparc) vaa.c vaa.i
GNU CPP version 2.8.1 (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/sparc-sun-solaris2.5/include
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.8.1/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.8.1/cc1 vaa.i -quiet -dumpbase vaa.c -O -version -o va
a.s
GNU C version 2.8.1 (sparc-sun-solaris2.5) compiled by GNU C version 2.8.1.
/usr/ccs/bin/as -V -Qy -s -o vaa.o vaa.s
/usr/ccs/bin/as: WorkShop Compilers 4.2 dev 13 May 1996
/usr/ccs/bin/ld -V -Y P,/usr/ccs/lib:/usr/lib -Qy /usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.8.1/
crt1.o /usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.8.1/crti.o /usr/ccs/lib/values-Xa.o /usr/local/l
ib/gcc-lib/sparc-sun-solaris2.5/2.8.1/crtbegin.o -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.8.1
-L/usr/ccs/bin -L/usr/ccs/lib -L/usr/local/lib vaa.o -lgcc -lc -lgcc /usr/local/lib/gcc-lib/sparc-sun
-solaris2.5/2.8.1/crtend.o /usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.8.1/crtn.o
ld: Software Generation Utilities (SGU) SunOS/ELF (LK-2.0 (S/I) - versioning)
% a.out
Bus error (core dumped)
List.1 vaa.c
#include <stdio.h>
#include <stdarg.h>
int fvaa(int cnt,...)
{va_list ap;
va_start(ap,cnt);
va_end(ap);
return(0);
}
int main(void)
{int i;
double a;
i=0;
a=1;
fvaa(i /* this integer argument is not treated as variable argument. */
,i /* this integer argument is treated as variable argument. */
/*0 1 2 3 4 5 6 7 8 9 a b c d e f */
,a,a,a,a,a,a,a,a,a,a,a,a,a,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a,a,a,a,a,a,a /* a */
,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a /* b */
,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a /* c */
,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a /* d */
,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a /* e */
,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a /* f */
);
return(0);
}
thank you.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vaa.tar.gz
Type: application/x-gzip
Size: 7236 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/19991207/fbbc89f2/attachment.bin>
More information about the Gcc-bugs
mailing list