+2016-11-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR sanitizer/69278
+ * opts.c (parse_sanitizer_options): For -fsanitize=undefined,
+ restore enabling also SANITIZE_UNREACHABLE and SANITIZE_RETURN.
+
2016-11-23 Jakub Jelinek <jakub@redhat.com>
PR middle-end/69183
/* 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
2016-11-23 Jakub Jelinek <jakub@redhat.com>
+ PR sanitizer/69278
+ * g++.dg/ubsan/return-7.C: New test.
+ * c-c++-common/ubsan/unreachable-4.c: New test.
+
PR tree-optimization/78482
* gcc.dg/torture/pr78482.c (c, d): Use signed char instead of char.
(bar): New function.
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined" } */
+/* { dg-shouldfail "ubsan" } */
+
+int
+main (void)
+{
+ __builtin_unreachable ();
+}
+ /* { dg-output "execution reached a __builtin_unreachable\\(\\) call" } */
--- /dev/null
+// { 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" }