[Proj] Submitting proj.4 to Google OSS Fuzz ?

Even Rouault even.rouault at spatialys.com
Tue May 23 05:49:15 PDT 2017


On mardi 23 mai 2017 14:16:41 CEST Thomas Knudsen wrote:
> In IEEE754 arithmetic, division by zero results in +/- infinity, not by a
> crash.
> 
> Hence, crashes are only expected if dividing by integer zero, as
> demonstrated below:
> 
> $ cat IEEE754_division_by_zero.c
> 
> #include <stdio.h>
> 
> int main (void) {
>   double dresult, dzero = 0, dten = 10;
>     int    iresult, izero = 0, iten = 10;
>   puts ("Dividing by double zero");
>   dresult = dten / dzero;
>   printf ("dresult = %g\n", dresult);
>   puts ("Dividing by integer zero");
>   iresult = iten / izero;
>   printf ("iresult = %d\n", iresult);
> }
> 
> $ gcc ieee754division_by_zero.c
> $ a
> Dividing by double zero
> dresult = 1.#INF
> Dividing by integer zero

https://stackoverflow.com/questions/3004095/division-by-zero-undefined-behavior-or-implementation-defined-in-c-and-or-c
has some interesting references.

So it would seem that according to the C standard, division by zero, either in integer
or floating-point case is undefined behaviour. And that's what -fsanitize=undefined must
check.

In practice on Intel-like CPUs, the behaviour is what you mention above,
but could potentially be different on other architectures, or with a compiler that would
implement the C standard in an extreme way (like "crash everytime we encounter
a situation that is 'unspecified bheaviour' in the standard")

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20170523/15e15cb8/attachment.html>


More information about the Proj mailing list