🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Piet van Oostrum Wed, 15 Feb 1989 17:08
Bug in g++ 1.32.0 for new.
#1687
Author: Piet van Oostrum
Date: Wed, 15 Feb 1989 17:08
86 lines
2553 bytes
I tried to mail this to bug-g++, but I have reasons to believe that that
failed. Sorry if you see this twice.

g++ generates incorrect code for new type [i] if type is a class.

The code tests for i being zero, but fails to put a NULL pointer in the
register where the result is delivered. I don't know if i==0 is correct
C++, but the test5[ab] programs from the library (libg++-1.25.0/tests)
actually use this (e.g. to initialize nil_Integer_rep).

The example is on a Sun3 OS3.
------------------------------------------------------------------------
The program:

#include <Integer.h>
extern myfunc(Integer *i);

main()
{
	int i;
	Integer *a = new Integer [i];
	myfunc (a);
}
------------------------------------------------------------------------

g++ -v -S temp1.cc  
g++ version 1.32.0 
 /usr/staff/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix temp1.cc /tmp/cca05970.cpp 
GNU CPP version 1.32 
 /usr/staff/lib/gcc-c++ /tmp/cca05970.cpp -quiet -dumpbase temp1.cc -noreg -version -o temp1.s 
GNU C++ version 1.32.0 (68k, MIT syntax) compiled by CC. 

------------------------------------------------------------------------
the code: (some initial stuff deleted)

_main:
	link a6,#-8
	moveml #0x3c20,sp@-
	movel a6@(-4),d3
	subql #1,d3
	tstl d3				test
	jlt L1074			branch if (i==0)
	movel a6@(-4),d0
	asll #2,d0
	movel d0,sp@-
	jbsr ___builtin_new
	movel d0,d2
	movel d2,d4
	addqw #4,sp
L1075:
	movel d4,a2
	movel a6,d0
	subql #4,d0
	tstl a2
	jne L1079
	pea 4:w
	jbsr ___builtin_new
	movel d0,a2
	addqw #4,sp
L1079:
	movel #__nil_Irep,a2@
	movel a2,d0
	movel d0,d1
	jra L1078
L1078:
	addql #4,d4
L1077:
	subql #1,d3
	moveq #-1,d5
	cmpl d3,d5
	jeq L1076
	jra L1075
L1076:
L1074:
	movel d2,a6@(-8)		<== d2 is not set if i==0
	movel a6@(-8),sp@-
	jbsr _myfunc
	addqw #4,sp
L1073:
	moveml a6@(-28),#0x43c
	unlk a6
	rts
-- 
Piet van Oostrum, Dept of Computer Science, University of Utrecht
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands
Telephone: +31-30-531806. piet@cs.ruu.nl (mcvax!hp4nl!ruuinf!piet)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads