On Tue, Apr 29, 2014 at 11:34:50AM +0200, Marek Polacek wrote: > Ran ubsan testsuite (-m32/-m64) + bootstrap-ubsan on x86_64-linux, ok now? > > 2014-04-29 Marek Polacek <pola...@redhat.com> > > * gcc.c (sanitize_spec_function): Handle SANITIZE_FLOAT_DIVIDE. > * builtins.def: Initialize builtins even for SANITIZE_FLOAT_DIVIDE. > * flag-types.h (enum sanitize_code): Add SANITIZE_FLOAT_DIVIDE. > * opts.c (common_handle_option): Add -fsanitize=float-divide-by-zero. > c-family/ > * c-ubsan.c (ubsan_instrument_division): Handle REAL_TYPEs. Perform > INT_MIN / -1 sanitization only for integer types. > c/ > * c-typeck.c (build_binary_op): Call ubsan_instrument_division > also when SANITIZE_FLOAT_DIVIDE is on. > cp/ > * typeck.c (cp_build_binary_op): Call ubsan_instrument_division > even when SANITIZE_FLOAT_DIVIDE is on. Set doing_div_or_mod even > for non-integer types. > testsuite/ > * c-c++-common/ubsan/div-by-zero-5.c: Fix formatting. > * c-c++-common/ubsan/float-div-by-zero-1.c: New test.
> +int > +main (void) > +{ > + volatile float a = 1.3f; > + volatile double b = 0.0; > + volatile int c = 4; > + > + a / b; > + a / 0.0; > + 2.7f / b; > + 3.6 / (b = 0.0, b); > + c / b; > + b / c; Please assign the result of the divisions to some other volatile variables, otherwise I don't see why the compiler couldn't optimize them away all. Otherwise looks good to me. Jakub