This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PR54693] loss of debug info in jump threading and loop ivopts


Alexandre Oliva <aoliva@redhat.com> writes:

> +int
> +main ()
> +{
> +  int i;
> +  char c;
> +  char arr[11];
> +
> +  for (i = 0; i < 10; i++)
> +    {
> +      c = 0x30 + i;
> +      foo (&arr[i], c); /* { dg-final { gdb-test 24 "i" "c - 48" } } */
> +    }
> +
> +  __builtin_printf ("arr = %s\n", arr);

The string is not 0-terminated, which causes random characters to be
output, and could even result in a spurious crash.  Installed as
obvious.

Andreas.

	* gcc.dg/guality/pr54693.c: Null-terminate arr.

diff --git a/gcc/testsuite/gcc.dg/guality/pr54693.c b/gcc/testsuite/gcc.dg/guality/pr54693.c
index adc2dfd..b852c06 100644
--- a/gcc/testsuite/gcc.dg/guality/pr54693.c
+++ b/gcc/testsuite/gcc.dg/guality/pr54693.c
@@ -21,6 +21,7 @@ main ()
       c = 0x30 + i;
       foo (&arr[i], c); /* { dg-final { gdb-test 22 "i" "c - 48" } } */
     }
+  arr[10] = 0;
 
   __builtin_printf ("arr = %s\n", arr);
   return 0;
-- 
1.8.1

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]