diff mbox

Do not enable -fcheck-pointer-bounds w/ -fsanitize=bounds

Message ID 5e6c535a-24a3-a5bf-e2d6-fb4f4267e82c@suse.cz
State New
Headers show

Commit Message

Martin Liška June 9, 2016, 9:12 a.m. UTC
Hello.

I've prepared patch for the PR that is very similar to what was done in PR65044.
I've been currently testing the patch on x86_64-linux.

Ready to be installed after it finishes?
Thanks,
Martin

Comments

Jeff Law June 9, 2016, 3:54 p.m. UTC | #1
On 06/09/2016 03:12 AM, Martin Liška wrote:
> Hello.
>
> I've prepared patch for the PR that is very similar to what was done in PR65044.
> I've been currently testing the patch on x86_64-linux.
>
> Ready to be installed after it finishes?
OK.
jeff
diff mbox

Patch

From a04b8e09388499686aabd401ef33e2821f3f0809 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 9 Jun 2016 11:09:07 +0200
Subject: [PATCH] Do not enable -fcheck-pointer-bounds w/ -fsanitize=bounds

gcc/ChangeLog:

2016-06-09  Martin Liska  <mliska@suse.cz>

	PR sanitizer/71458
	* toplev.c (process_options): Do not enable -fcheck-pointer-bounds
	w/ -fsanitize=bounds.

gcc/testsuite/ChangeLog:

2016-06-09  Martin Liska  <mliska@suse.cz>

	* gcc.target/i386/pr71458.c: New test.
---
 gcc/testsuite/gcc.target/i386/pr71458.c | 7 +++++++
 gcc/toplev.c                            | 9 +++++++++
 2 files changed, 16 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr71458.c

diff --git a/gcc/testsuite/gcc.target/i386/pr71458.c b/gcc/testsuite/gcc.target/i386/pr71458.c
new file mode 100644
index 0000000..27e7764
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr71458.c
@@ -0,0 +1,7 @@ 
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=bounds" } */
+/* { dg-error "-fcheck-pointer-bounds is not supported with -fsanitize=bounds" "" { target *-*-* } 0 } */
+
+enum {} a[0];
+void fn1(int);
+void fn2() { fn1(a[-1]); }
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 543b8a3..f51d2cb 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1276,6 +1276,15 @@  process_options (void)
 		    "Address Sanitizer");
 	  flag_check_pointer_bounds = 0;
 	}
+
+      if (flag_sanitize & SANITIZE_BOUNDS)
+	{
+	  error_at (UNKNOWN_LOCATION,
+		    "-fcheck-pointer-bounds is not supported with "
+		    "-fsanitize=bounds");
+	  flag_check_pointer_bounds = 0;
+	}
+
     }
 
   /* One region RA really helps to decrease the code size.  */
-- 
2.8.3