"Sofer, Yuval" <Yuval_Sofer@bmc.com> writes:
> I have compiled 8.3.7 on HP-Itanium
> After the build I have continued to the tests (gmake check)
> One of the tests failed (division by zero error test)
Hm, what compiler and what optimization level? We have seen a report
or two about this before, all from people using gcc on non-mainstream
architectures. So far as I can tell it's a compiler bug. The code
in int84div looks like
int64 arg1 = PG_GETARG_INT64(0);
int32 arg2 = PG_GETARG_INT32(1);
int64 result;
if (arg2 == 0)
ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = arg1 / arg2;
and the only way to get the behavior you're showing is if the division
is executing (and causing a trap) before control is passed to ereport().
So apparently the compiler is forgetting that division can have a side
effect (ie machine trap) and thinking it's safe to reorder the
operations.
regards, tom lane