Hi,
I've applied the patch for Denis in r246909. Also, the issue seems to
appear at least in GCC 6 (and perhaps in 5, I need to check).
Is it OK to apply the patch on branches after testing?
-Maxim
On 13/04/17 17:03, Jakub Jelinek wrote:
On Thu, Apr 13, 2017 at 04:55:52PM +0300, Denis Khalikov wrote:
+2017-04-13 Denis Khalikov <d.khali...@partner.samsung.com>
+
+ PR sanitizer/80414
+ * ubsan.c (ubsan_expand_bounds_ifn): Fix wrong tree val generation
+ for 32 bit host.
I'd say here instead ...): Pass original index to ubsan_encode_value.
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/bounds-15.c
@@ -0,0 +1,13 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+
+int main()
+{
+ long long offset = 10;
+ char array[10];
+ char c = array[offset];
+ return 0;
+}
+
+/* { dg-output "\[^\n\r]*index 10 out of bounds for type 'char \\\[10\\\]'" }
*/
And the initial \[^\n\r]* makes no sense, there is no ^, so the regexp tries
to match anywhere in the output (which is sufficient here). Other tests
use /* { dg-output "\[^\n\r]*something..." } */, but only in the second
and further dg-output directive (the regexps from all dg-output are
concatenated together). So just use
/* { dg-output "index 10 out of bounds for type 'char \\\[10\\\]'" } */
Ok for trunk with those changes, thanks.
Jakub