On Mon, 28 Apr 2014, Marek Polacek wrote:

This patch implements -fsanitize=float-divide-by-zero option that can
be used to detect division by zero even when using floating types.
Most of the code in ubsan_instrument_division was ready for this
so this was mainly about handling REAL_TYPE there.

Ideally this would all be unneeded, you would compile your program with pragma stdc fenv_access on, on glibc you would call feenableexcept(FE_DIVBYZERO) at the beginning of the program, done (I may have listed the wrong function, I am always confused by those names).

But I guess we won't be there anytime soon, so in the mean time...

Since division by a floating point zero can be a valid way of
obtaining infinities and NaNs, I'm not 100% sure this ought to be
enabled by default (that is, enabled when -fsanitize=undefined is
specified).

Please don't enable it with "undefined". As you say, it is well defined (except when finite-math-only is in effect). If you want a meta-category for this kind of valid thing, maybe -fsanitize=unusual or -fsanitize=suspicious.

--
Marc Glisse

Reply via email to