https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70875
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Ah, you're right, the buffer overflow is nasty, even when we diagnose at runtime it is better not to let it continue into the actual UB. Will test following then: 2018-03-01 Jakub Jelinek <ja...@redhat.com> PR sanitizer/70875 * gcc.dg/ubsan/bounds-3.c: Add -fno-sanitize-recover=bounds to dg-options and dg-shouldfail "ubsan" directive. --- gcc/testsuite/gcc.dg/ubsan/bounds-3.c.jj 2016-05-06 15:09:06.361758948 +0200 +++ gcc/testsuite/gcc.dg/ubsan/bounds-3.c 2018-03-01 17:44:13.722455985 +0100 @@ -1,6 +1,7 @@ /* PR sanitizer/70875 */ /* { dg-do run } */ -/* { dg-options "-fsanitize=bounds" } */ +/* { dg-options "-fsanitize=bounds -fno-sanitize-recover=bounds" } */ +/* { dg-shouldfail "ubsan" } */ int foo (int n, int k)