Path: utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!mullian.ee.mu.OZ.AU!meb From: meb@mullian.ee.mu.OZ.AU (Matthew Barry) Newsgroups: gnu.gcc.bug Subject: gcc 1.36 bug on sparcs Message-ID: <8911210850.941@orac.ee.mu.OZ.AU> Date: 22 Nov 89 00:50:38 GMT Sender: daemon@tut.cis.ohio-state.edu Reply-To: meb@mullian.ee.mu.oz.au Distribution: gnu Organization: GNUs Not Usenet Lines: 233 The following code causes a segmentation violation on SparcStations and Sun 4s with gcc 1.36 (configured with config.gcc sun4-os4): ----------- #include #include #ifdef __STDC__ char *inet_ntoa( struct in_addr ); #else char *inet_ntoa(); #endif main() { u_long x = 0x80fa5015; struct in_addr w; w.S_un.S_addr = htonl( x ); printf( inet_ntoa( w ) ); } ----------- 103 % gcc -v -g t.c gcc version 1.36 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ t.c /tmp/cca00925.cpp GNU CPP version 1.36 /usr/local/lib/gcc-cc1 /tmp/cca00925.cpp -quiet -dumpbase t.c -g -version -o /tmp/cca00925.s GNU C version 1.36 (sparc) compiled by GNU C version 1.36. default target switches: -mfpu -mepilogue /usr/local/lib/gcc-as -o t.o /tmp/cca00925.s /usr/local/lib/gcc-ld -e start -dc -dp -Bstatic /lib/crt0.o t.o /usr/local/lib/gcc-gnulib -lg -lc ------------ The assmebler output from gcc is: gcc_compiled.: .stabs "t.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 .stabs "u_char:t11",128,0,0,0 .stabs "u_short:t8",128,0,0,0 .stabs "u_int:t4",128,0,0,0 .stabs "u_long:t5",128,0,0,0 .stabs "ushort:t8",128,0,0,0 .stabs "uint:t4",128,0,0,0 .stabs "_physadr:T16=s4r:17=ar1;0;0;1,0,32;;",128,0,0,0 .stabs "physadr:t18=*16",128,0,0,0 .stabs "label_t:T19=s8val:20=ar1;0;1;1,0,64;;",128,0,0,0 .stabs "label_t:t19",128,0,0,0 .stabs "_quad:T21=s8val:22=ar1;0;1;3,0,64;;",128,0,0,0 .stabs "quad:t21",128,0,0,0 .stabs "daddr_t:t3",128,0,0,0 .stabs "caddr_t:t23=*2",128,0,0,0 .stabs "ino_t:t5",128,0,0,0 .stabs "swblk_t:t3",128,0,0,0 .stabs "size_t:t1",128,0,0,0 .stabs "time_t:t3",128,0,0,0 .stabs "dev_t:t6",128,0,0,0 .stabs "off_t:t3",128,0,0,0 .stabs "uid_t:t8",128,0,0,0 .stabs "gid_t:t8",128,0,0,0 .stabs "key_t:t3",128,0,0,0 .stabs "fd_mask:t3",128,0,0,0 .stabs "fd_set:T24=s32fds_bits:25=ar1;0;7;3,0,256;;",128,0,0,0 .stabs "fd_set:t24",128,0,0,0 .stabs "addr_t:t23",128,0,0,0 .text .align 4 .global _main .proc 1 _main: .stabn 68,0,12,LM1 LM1: !#PROLOGUE# 0 save %sp,-128,%sp !#PROLOGUE# 1 LBB2: .stabn 68,0,13,LM2 LM2: sethi %hi(-2131079147),%o1 or %lo(-2131079147),%o1,%o1 st %o1,[%fp-20] .stabn 68,0,16,LM3 LM3: ld [%fp-20],%o1 st %o1,[%fp-32] .stabn 68,0,18,LM4 LM4: ld [%fp-32],%o0 call _inet_ntoa,0 nop mov %o0,%o0 mov %o0,%o0 call _printf,0 nop LBE2: .stabn 68,0,19,LM5 LM5: L1: ret restore .stabs "sockaddr_in:T26=s16sin_family:6,0,16;sin_port:8,16,16;sin_addr:27=xsin_addr:,32,32;sin_zero:28=ar1;0;7;2,64,64;;",128,0,0,0 .stabs "in_addr:T27=s4S_un:29=u4S_un_b:30=s4s_b1:11,0,8;s_b2:11,8,8;s_b3:11,16,8;s_b4:11,24,8;;,0,32;S_un_w:31=s4s_w1:8,0,16;s_w2:8,16,16;;,0,32;S_addr:5,0,32;;,0,32;;",128,0,0,0 .stabs "main:F1",36,0,0,_main .stabs "x:5",128,0,0,-20 .stabs "w:27",128,0,0,-32 .stabn 192,0,0,LBB2 .stabn 224,0,0,LBE2 -------------------------------- Cc produces the following assembler: .stabs "/mount/mullian/elec/cs/meb/msc/netblt/",0144,0,0,LL0 .stabs "t.c",0144,0,0,LL0 LL0: .stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",0x80,0,0,0 .stabs "char:t(0,2)=r(0,2);0;127;",0x80,0,0,0 .stabs "long:t(0,3)=r(0,1);-2147483648;2147483647;",0x80,0,0,0 .stabs "short:t(0,4)=r(0,1);-32768;32767;",0x80,0,0,0 .stabs "unsigned char:t(0,5)=r(0,1);0;255;",0x80,0,0,0 .stabs "unsigned short:t(0,6)=r(0,1);0;65535;",0x80,0,0,0 .stabs "unsigned long:t(0,7)=r(0,1);0;-1;",0x80,0,0,0 .stabs "unsigned int:t(0,8)=r(0,1);0;-1;",0x80,0,0,0 .stabs "float:t(0,9)=r(0,1);4;0;",0x80,0,0,0 .stabs "double:t(0,10)=r(0,1);8;0;",0x80,0,0,0 .stabs "void:t(0,11)=(0,11)",0x80,0,0,0 .stabs "???:t(0,12)=(0,1)",0x80,0,0,0 .stabs "/usr/include/sys/types.h",0202,0,0,0 .seg "data" .stabs "/usr/include/sys/sysmacros.h",0202,0,0,0 .stabn 0242,0,0,0 .stabs "u_char:t(0,5)",0x80,0,1,-1275 .stabs "u_short:t(0,6)",0x80,0,2,-1275 .stabs "u_int:t(0,8)",0x80,0,4,-1275 .stabs "u_long:t(0,8)",0x80,0,4,-1275 .stabs "ushort:t(0,6)",0x80,0,2,-1275 .stabs "uint:t(0,8)",0x80,0,4,-1275 .stabs "_physadr:T(1,1)=s4r:(1,2)=ar(0,1);0;0;(0,1),0,32;;",0x80,0,4,-1275 .stabs "physadr:t(1,3)=*(1,1)",0x80,0,4,-1275 .stabs "label_t:T(1,4)=s8val:(1,5)=ar(0,1);0;1;(0,1),0,64;;",0x80,0,8,-1275 .stabs "label_t:t(1,4)",0x80,0,8,-1275 .stabs "_quad:T(1,6)=s8val:(1,5),0,64;;",0x80,0,8,-1275 .stabs "quad:t(1,6)",0x80,0,8,-1275 .stabs "daddr_t:t(0,1)",0x80,0,4,-1275 .stabs "caddr_t:t(1,7)=*(0,2)",0x80,0,1,-1275 .stabs "ino_t:t(0,8)",0x80,0,4,-1275 .stabs "swblk_t:t(0,1)",0x80,0,4,-1275 .stabs "size_t:t(0,1)",0x80,0,4,-1275 .stabs "time_t:t(0,1)",0x80,0,4,-1275 .stabs "dev_t:t(0,4)",0x80,0,2,-1275 .stabs "off_t:t(0,1)",0x80,0,4,-1275 .stabs "uid_t:t(0,6)",0x80,0,2,-1275 .stabs "gid_t:t(0,6)",0x80,0,2,-1275 .stabs "key_t:t(0,1)",0x80,0,4,-1275 .stabs "fd_mask:t(0,1)",0x80,0,4,-1275 .stabs "fd_set:T(1,8)=s32fds_bits:(1,9)=ar(0,1);0;7;(0,1),0,256;;",0x80,0,32,-1275 .stabs "fd_set:t(1,8)",0x80,0,32,-1275 .stabs "addr_t:t(1,7)",0x80,0,1,-1275 .stabn 0242,0,0,0 .stabs "/usr/include/netinet/in.h",0202,0,0,0 .stabs "in_addr:T(3,1)=s4S_un:(3,2)=u4S_un_b:(3,3)=s4s_b1:(0,5),0,8;s_b2:(0,5),8,8;s_b3:(0,5),16,8;s_b4:(0,5),24,8;;,0,32;S_un_w:(3,4)=s4s_w1:(0,6),0,16;s_w2:(0,6),16,16;;,0,32;S_addr:(0,8),0,32;;,0,32;;",0x80,0,4,-1275 .stabs "sockaddr_in:T(3,5)=s16sin_family:(0,4),0,16;sin_port:(0,6),16,16;sin_addr:(3,1),32,32;sin_zero:(3,6)=ar(0,1);0;7;(0,2),64,64;;",0x80,0,16,-1275 .stabn 0242,0,0,0 .stabs "main:F(0,1)",0x24,0,4,_main .seg "text" .stabn 0104,0,12,LL1 LL1: .proc 04 .global _main _main: !#PROLOGUE# 0 sethi %hi(LF13),%g1 add %g1,%lo(LF13),%g1 save %sp,%g1,%sp !#PROLOGUE# 1 .stabn 0104,0,12,LL2 LL2: .stabs "x:(0,8)",0x80,0,4,-4 .stabn 0104,0,13,LL3 LL3: set -0x7f05afeb,%o0 st %o0,[%fp+-0x4] .stabs "w:(3,1)",0x80,0,4,-8 .stabn 0300,0,2,LL4 LL4: .stabn 0104,0,16,LL5 LL5: ld [%fp+-0x4],%o0 st %o0,[%fp+-0x8] .stabn 0104,0,18,LL6 LL6: add %sp,LP13,%o0 sub %fp,0x8,%o1 ld [%o1],%o2 st %o2,[%o0+0] call _inet_ntoa,1 nop call _printf,1 nop .stabn 0340,0,2,LL7 LL7: .stabn 0104,0,19,LL8 LL8: mov 0,%o0 LE13: mov %o0,%i0 ret restore .optim "-O~Q~R~S" LF13 = -112 LP13 = 96 LT13 = 104 .seg "data"