jfp@practic.com (John F. Peters) (01/08/90)
DESCRIPTION: gcc-1.36(ns32k) running in Vax 4.3bsd-tahoe, md -> ./config/ns32k.md, tm.h -> ./config/tm-sequent.h: Dereferencing pointer in memory gives incorrect assembly code. REPEAT-BY: Run this script using your local name for ns32k gcc: ------------------------------------------------------------------------------ set -v cat > badref.c <<"EOF" char *cp; main() { char ch; ch = cp[0]; ch = cp[1]; } EOF gcc32k -v -g -S badref.c cat badref.s ------------------------------------------------------------------------------ There is an incorrect address reference in the assembler output. Reference to cp[0] yields "0(cp)", should be "0(cp(sb))". Reference to cp[1] yields "1(cp(sb))" which is correct. This is my script output, with the error marked: ------------------------------------------------------------------------------ cat > badref.c <<"EOF" char *cp; main() { char ch; ch = cp[0]; ch = cp[1]; } EOF gcc32k -v -g -S badref.c gcc version 1.36 /usr/gnu/lib32k/gcc-cpp -v -undef -D__GNUC__ -Dns32000 -Dsequent -Dunix -D__ns32000__ -D__sequent__ -D__unix__ badref.c /usr/tmp/cc001736.cpp GNU CPP version 1.36 /usr/gnu/lib32k/gcc-cc1 /usr/tmp/cc001736.cpp -quiet -dumpbase badref.c -g -version -o badref.s GNU C version 1.36 (32000, Sequent syntax) compiled by GNU C version 1.36. default target switches: -m32081 cat badref.s #NO_APP gcc_compiled.: .stabs "badref.c",100,0,0,Ltext Ltext: .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0 .stabs "char:t2=r2;0;127;",128,0,0,0 .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0 .stabs "long long int:t7=r1;0;-1;",128,0,0,0 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0 .stabs "signed char:t10=r1;-128;127;",128,0,0,0 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0 .stabs "float:t12=r1;4;0;",128,0,0,0 .stabs "double:t13=r1;8;0;",128,0,0,0 .stabs "long double:t14=r1;8;0;",128,0,0,0 .stabs "void:t15=15",128,0,0,0 .text .align 1 .globl _main _main: .stabd 68,0,4 enter [],4 LBB2: .stabd 68,0,7 movb 0(_cp),-4(fp) <==WRONG .stabd 68,0,8 movb 1(_cp(sb)),-4(fp) <==RIGHT LBE2: .stabd 68,0,9 L1: exit [] ret 0 .stabs "main:F1",36,0,0,_main .stabs "ch:2",128,0,0,-4 .stabn 192,0,0,LBB2 .stabn 224,0,0,LBE2 .stabs "cp:G16=*2",32,0,0,0 .comm _cp,4 ------------------------------------------------------------------------------ jfp@practic.com