weiss@maxzilla.Encore.COM (Rick Weiss) (01/12/89)
Greetings, I've encountered a problem with G++ 1.32 on an Encore Multimax (NS32000) in the apparent management of temporary stack space. In re-using pending stack space where the space needed is smaller than the space available it seems to get confused. The following example should help clarify the problem: Compile the following source: g++ version 1.32.0 /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dns32000 -Dn16 -Dns16000 -Dns32332 -Dunix -D__OPTIMIZE__ tuna.cc /tmp/cc011412.cpp GNU CPP version 1.32 /usr/local/lib/gcc-c++ /tmp/cc011412.cpp -quiet -dumpbase tuna.cc -fchar-charconst -opt -version -o tuna.s GNU C++ version 1.32.0 (32000, Encore syntax) compiled by CC. In function int main (): tuna.cc:30: warning: variable `x' never used ----------------------------------------------------------------------------- #include "stream.h" class Point { long xc; long yc; public: Point(long newx=0, long newy =0) { xc=newx; yc=newy; } friend Point operator*(Point p, long i) { return Point(i*p.xc, i*p.yc); } friend Point operator*(long i, Point p) { return Point(i*p.xc, i*p.yc); } friend Point operator/(Point p, long i) { return Point(p.xc/i, p.yc/i); } friend Point operator/(long i, Point p) { return Point(i/p.xc, i/p.yc); } }; class Rect { Point or; Point sz; public: Rect(Point o, Point s) { or=o; sz=s; } Point origin() { return or; } Point size() { return sz; } }; main () { Rect r( Point ( 10, 10 ), Point ( 20, 20 ) ); // problem occurs with code generated for the following line: Point x = r.size()*10/100; } ----------------------------------------------------------------------------- generates the following code ----------------------------------------------------------------------------- .align 16 .globl _main _main: enter [r3,r4],24 adjspb $20 # we add 20 to stack addr 12(sp),r0 addr @20,tos # we add another 4 addr @20,tos # we add another 4 movd r0,tos # we add another 4 addr _Point_PSPoint_lSI_lSI,r3 jsr r3 adjspb $-12 # back to 20 addr 4(sp),r0 addr @10,tos # we add another 4 addr @10,tos # we add another 4 movd r0,tos # we add another 4 jsr r3 adjspb $-12 # back to 20 addr -16(fp),r3 movd r3,0(sp) bsr ?_Rect_PSRect_SPoint_SPoint # we still have 20 on stack addr @100,8(sp) # <- we should have the stack at 12, or addr tos,r4 adjspb $4 # <- we should be adding another 12 here addr @10,8(sp) addr tos,r2 movd r3,tos bsr ?_size_PSRect cmpqd $0,tos # adjsp -4 movd r4,r2 bsr ?_op$mult_expr_SPoint_lSI adjspb $-12 addr -24(fp),r2 bsr ?_op$trunc_div_expr_SPoint_lSI adjspb $-12 exit [r4,r3] ret 0 ----------------------------------------------------------------------------- Good luck! Rick