https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110860
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> --- GCC's ubsan doesn't seem to diagnose this rule: "A prvalue of a floating-point type can be converted to a prvalue of an integer type. The conversion truncates; that is, the fractional part is discarded. The behavior is undefined if the truncated value cannot be represented in the destination type." There's no ubsan diagnostic for: unsigned long i = -HUGE_VAL; So it doesn't complain about adding log10(0) to a size_t. I can reproduce it with Clang though, and have tested a fix.