On Mon, Nov 23, 2015 at 10:48:30AM +0300, Maxim Ostapenko wrote:
> Index: gcc/testsuite/c-c++-common/asan/halt_on_error-1.c
> ===================================================================
> --- gcc/testsuite/c-c++-common/asan/halt_on_error-1.c (revision 0)
> +++ gcc/testsuite/c-c++-common/asan/halt_on_error-1.c (working copy)
> @@ -0,0 +1,23 @@
> +/* Test recovery mode.  */
> +/* { dg-do run } */
> +/* { dg-options "-fsanitize-recover=address" } */
> +/* { dg-set-target-env-var ASAN_OPTIONS "halt_on_error=false" } */
> +
> +#include <string.h>
> +
> +volatile int ten = 10;
> +
> +int main() {
> +  char x[10];
> +  memset(x, 0, 11);

Please use ten + 1 instead of 11 here.
With -fsanitize=address, there will be padding immediately after the
variable, therefore otherwise (if the compiler does not see we are
running into undefined behavior) the testcase might be ok.

> --- gcc/testsuite/c-c++-common/asan/halt_on_error-2.c (revision 0)
> +++ gcc/testsuite/c-c++-common/asan/halt_on_error-2.c (working copy)
> @@ -0,0 +1,24 @@
> +/* Test recovery mode.  */
> +/* { dg-do run } */
> +/* { dg-options "-fsanitize-recover=address" } */
> +/* { dg-set-target-env-var ASAN_OPTIONS "halt_on_error=true" } */
> +/* { dg-shouldfail "asan" } */
> +
> +#include <string.h>
> +
> +volatile int ten = 10;
> +
> +int main() {
> +  char x[10];
> +  memset(x, 0, 11);

Likewise.

Otherwise OK for trunk.

        Jakub

Reply via email to