From patchwork Wed Jan 9 11:56:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [PR54693] loss of debug info in jump threading and loop ivopts Date: Wed, 09 Jan 2013 01:56:32 -0000 From: Andreas Schwab X-Patchwork-Id: 210702 Message-Id: To: Alexandre Oliva Cc: gcc-patches@gcc.gnu.org Alexandre Oliva 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;