[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

armel: floating point zero division does not raise exception



On armel, dividing a flow by zero does not raise an exception, as it
does on other platforms.

$ cat divbyzero.c
#include <stdlib.h>
#include <stdio.h>
#include <fenv.h>

int main(int argc, char **argv)
{
	float one = 1.0;

	feclearexcept(FE_ALL_EXCEPT);

	printf("Dividing by zero produces: ");
	one = one / 0.0;
	if (fetestexcept(FE_DIVBYZERO)) {
		printf("FE_DIVBYZERO\n");
	} else if (fetestexcept(FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW)) {
		printf("Something else\n");
	} else {
		printf("Nothing\n");
	}

	exit(EXIT_SUCCESS);
}

$ gcc -o divbyzero divbyzero.c -lm

# amd64
$ ./divbyzero
Dividing by zero produces: FE_DIVBYZERO

# armel (tested on abel.debian.org)
$ ./divbyzero
Dividing by zero produces: Nothing


I discovered this by tracing a failing test suite of src:scikit-learn
back src:numpy, which did not detect the division by zero. I reported
this upstream [1], where they pointed out that this is probably a
platform thing.

Any suggestions on how to deal with this? Is this really a bug, or is my
test program above missing something?

[1] https://github.com/numpy/numpy/issues/15562 


Reply to: