[gnu.g++.bug] gcc-ld++ or gcc-as1.34 bug on Sun 3

tom@tnosoes.UUCP (Tom Vijlbrief) (08/23/89)

I found a bug in either gcc-ld++ or gas1.34.

The following program dumps core when assembled with gas,
but not when assembled with the sun as.

Deleting 'static' eliminates the problem.

I'm running this on a Sun 3/60 which has a debugging malloc package.
The assembler output differs, the assemblers use a different alignment:

Sun as:

00000088 T __GLOBAL_$I$t_c
         U ___builtin_new
000000a0 b _debug
00000002 C _gBlue_table
0000009c D _gColor_len
00000002 C _gGreen_table
00000002 C _gRed_table
00000054 T _main
         U _malloc
         U _malloc_debug
0000000a t _mydebug_PSmydebug
         U _write
00000000 t gcc_compiled.

gcc-as:

0000008a T __GLOBAL_$I$t_c
         U ___builtin_new
000000a4 b _debug
00000002 C _gBlue_table
000000a0 D _gColor_len
00000002 C _gGreen_table
00000002 C _gRed_table
00000056 T _main
         U _malloc
         U _malloc_debug
0000000a t _mydebug_PSmydebug
         U _write
00000000 t gcc_compiled.
===================t.c============================

class mydebug {
public:
  mydebug() { malloc_debug(2); write(2, "Running\n", 8); }
};

static mydebug debug;

main()
{
  malloc(36);
  malloc(38);
}
==============================
g++ t.c /usr/lib/debug/malloc.o -v
g++ version 1.35.0
 /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 t.c /tmp/cca26492.cpp
GNU CPP version 1.35
 /usr/local/lib/gcc-cc1plus /tmp/cca26492.cpp -quiet -dumpbase t.c -noreg -version -o /tmp/cca26492.s
GNU C++ version 1.35.0 (68k, MIT syntax) compiled by GNU C version 1.35.
In method struct mydebug *mydebug::mydebug ():
t.c:3: warning: implicit declaration of function `malloc_debug'
t.c:3: warning: implicit declaration of function `write'
In function int main ():
t.c:10: warning: implicit declaration of function `malloc'
 /usr/local/lib/gcc-as -mc68020 /tmp/cca26492.s -o t.o
 /usr/local/lib/gcc-ld++ -C /usr/local/lib/crt0+.o /lib/Mcrt1.o t.o /usr/lib/debug/malloc.o -lg++ /usr/local/lib/gcc-gnulib -lc
tom@sunflare:~/src/CC> a.out
Running
Bad free list pointer (0x2090e)
 
IOT trap (core dumped)
========================
replace gcc-as with as:
===========================
tom@sunflare:~/src/CC> 
g++ t.c /usr/lib/debug/malloc.o -v
g++ version 1.35.0
 /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 t.c /tmp/cca26499.cpp
GNU CPP version 1.35
 /usr/local/lib/gcc-cc1plus /tmp/cca26499.cpp -quiet -dumpbase t.c -noreg -version -o /tmp/cca26499.s
GNU C++ version 1.35.0 (68k, MIT syntax) compiled by GNU C version 1.35.
In method struct mydebug *mydebug::mydebug ():
t.c:3: warning: implicit declaration of function `malloc_debug'
t.c:3: warning: implicit declaration of function `write'
In function int main ():
t.c:10: warning: implicit declaration of function `malloc'
 as -mc68020 /tmp/cca26499.s -o t.o
 /usr/local/lib/gcc-ld++ -C /usr/local/lib/crt0+.o /lib/Mcrt1.o t.o /usr/lib/debug/malloc.o -lg++ /usr/local/lib/gcc-gnulib -lc
tom@sunflare:~/src/CC> a.out
Running
tom@sunflare:~/src/CC> 

===============================================================================
Tom Vijlbrief
TNO Institute for Perception
P.O. Box 23				Phone: +31 34 63 562 11
3769 ZG  Soesterberg			E-mail: tnosoes!tom@mcvax.cwi.nl
The Netherlands				    or:	uunet!mcvax!tnosoes!tom
===============================================================================