On November 23, 2016 8:33:54 PM GMT+01:00, Jakub Jelinek <ja...@redhat.com> 
wrote:
>Hi!
>
>As mentioned in the PR, the r240491 change broke -fsanitize=undefined,
>which no longer enables -fsanitize=unreachable or -fsanitize=return.
>That is undesirable change, we only want not to enable
>-fsanitize-recover=unreachable,return on -fsanitize-recover=undefined.
>
>Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok
>for
>trunk?

OK.

Richard.

>2016-11-23  Jakub Jelinek  <ja...@redhat.com>
>
>       PR sanitizer/69278
>       * opts.c (parse_sanitizer_options): For -fsanitize=undefined,
>       restore enabling also SANITIZE_UNREACHABLE and SANITIZE_RETURN.
>
>       * g++.dg/ubsan/return-7.C: New test.
>       * c-c++-common/ubsan/unreachable-4.c: New test.
>
>--- gcc/opts.c.jj      2016-11-23 16:47:34.000000000 +0100
>+++ gcc/opts.c 2016-11-23 18:25:05.400325912 +0100
>@@ -1558,7 +1558,8 @@ parse_sanitizer_options (const char *p,
>               /* Do not enable -fsanitize-recover=unreachable and
>                  -fsanitize-recover=return if -fsanitize-recover=undefined
>                  is selected.  */
>-              if (sanitizer_opts[i].flag == SANITIZE_UNDEFINED)
>+              if (code == OPT_fsanitize_recover_
>+                  && sanitizer_opts[i].flag == SANITIZE_UNDEFINED)
>                 flags |= (SANITIZE_UNDEFINED
>                           & ~(SANITIZE_UNREACHABLE | SANITIZE_RETURN));
>               else
>--- gcc/testsuite/g++.dg/ubsan/return-7.C.jj   2016-11-23
>18:27:16.525687072 +0100
>+++ gcc/testsuite/g++.dg/ubsan/return-7.C      2016-11-23 18:27:21.854620469
>+0100
>@@ -0,0 +1,27 @@
>+// { dg-do run }
>+// { dg-options "-fsanitize=undefined" }
>+// { dg-shouldfail "ubsan" }
>+
>+struct S { S (); ~S (); };
>+
>+S::S () {}
>+S::~S () {}
>+
>+int
>+foo (int x)
>+{
>+  S a;
>+  {
>+    S b;
>+    if (x)
>+      return 1;
>+  }
>+}
>+
>+int
>+main ()
>+{
>+  foo (0);
>+}
>+
>+// { dg-output "execution reached the end of a value-returning
>function without returning a value" }
>--- gcc/testsuite/c-c++-common/ubsan/unreachable-4.c.jj        2016-11-23
>18:25:57.692672348 +0100
>+++ gcc/testsuite/c-c++-common/ubsan/unreachable-4.c   2016-11-23
>18:26:05.961569001 +0100
>@@ -0,0 +1,10 @@
>+/* { dg-do run } */
>+/* { dg-options "-fsanitize=undefined" } */
>+/* { dg-shouldfail "ubsan" } */
>+
>+int
>+main (void)
>+{
>+  __builtin_unreachable ();
>+}
>+ /* { dg-output "execution reached a __builtin_unreachable\\(\\) call"
>} */
>
>       Jakub


Reply via email to