> I compiled successfully a code ported from gcc/linux that runs OK there.
> However, I'm getting stack underflow error when running it under Plan 9.
that often happens when a function that returns double has no external
declaration in scope where it's used,
and it gets the default type of int, so the result on the floating-point stack
is not popped at the point of call.
that applies even when it's called for side-effect.
double f(int);
void
g(void)
{
f(3);
}
h% 8c -S db.c
TEXT g+0(SB),0,$8
MOVL $3,AX
MOVL AX,(SP)
CALL ,f+0(SB)
FMOVDP F0,F0
RET ,
END ,
note the P (pop) suffix on FMOVDP
of course, the compiler will have complained about the missing
declaration unless you've told it otherwise.