9c1a633d96
As noted by Richi, in clang INT_MIN / -1 is instrumented under -fsanitize=signed-integer-overflow rather than -fsanitize=integer-divide-by-zero as we did and doing it in the former makes more sense, as it is overflow during division rather than division by zero. I've verified on godbolt that clang behaved that way since 3.2-ish times or so when sanitizers were added. Furthermore, we've been using -f{,no-}sanitize-recover=integer-divide-by-zero to decide on the float -fsanitize=float-divide-by-zero instrumentation _abort suffix. The case where INT_MIN / -1 is instrumented by one sanitizer and x / 0 by another one when both are enabled is slightly harder if the -f{,no-}sanitize-recover={integer-divide-by-zero,signed-integer-overflow} flags differ, then we need to emit both __ubsan_handle_divrem_overflow and __ubsan_handle_divrem_overflow_abort calls guarded by their respective checks rather than one guarded by check1 || check2. 2021-10-01 Jakub Jelinek <jakub@redhat.com> Richard Biener <rguenther@suse.de> PR sanitizer/102515 gcc/ * doc/invoke.texi (-fsanitize=integer-divide-by-zero): Remove INT_MIN / -1 division detection from here ... (-fsanitize=signed-integer-overflow): ... and add it here. gcc/c-family/ * c-ubsan.c (ubsan_instrument_division): Check the right flag_sanitize_recover bit, depending on which sanitization is done. Sanitize INT_MIN / -1 under SANITIZE_SI_OVERFLOW rather than SANITIZE_DIVIDE. If both SANITIZE_SI_OVERFLOW and SANITIZE_DIVIDE is enabled, neither check is known to be false and flag_sanitize_recover bits for those two aren't the same, emit both __ubsan_handle_divrem_overflow and __ubsan_handle_divrem_overflow_abort calls. gcc/c/ * c-typeck.c (build_binary_op): Call ubsan_instrument_division for division even for SANITIZE_SI_OVERFLOW. gcc/cp/ * typeck.c (cp_build_binary_op): Call ubsan_instrument_division for division even for SANITIZE_SI_OVERFLOW. gcc/testsuite/ * c-c++-common/ubsan/div-by-zero-3.c: Use -fsanitize=signed-integer-overflow instead of -fsanitize=integer-divide-by-zero. * c-c++-common/ubsan/div-by-zero-5.c: Likewise. * c-c++-common/ubsan/div-by-zero-4.c: Likewise. Add -fsanitize-undefined-trap-on-error. * c-c++-common/ubsan/float-div-by-zero-2.c: New test. * c-c++-common/ubsan/overflow-div-1.c: New test. * c-c++-common/ubsan/overflow-div-2.c: New test. * c-c++-common/ubsan/overflow-div-3.c: New test. |
||
---|---|---|
c++tools | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcody | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libiberty | ||
libitm | ||
libobjc | ||
liboffloadmic | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ar-lib | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
symlink-tree | ||
test-driver | ||
ylwrap |
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.