The test cases in analyzer/pr104308.c use uninitialized values in a way
that doesn't plumb through to the return value of the function.  This
allows the accesses to be deleted, which can result in the diagnostic
not firing.

gcc/testsuite/ChangeLog

        * gcc.dg/analyzer/pr104308.c (test_memmove_within_uninit):
        Return the result of the copy.
        (test_memcpy_From_uninit): Likewise.
---
I was worried this had something to do with this test failing on RISC-V.
I don't think that's actually the case (IIUC we're just not inlining the
memmove, which elides the diagnostic), but I'd already written it so I
figured I'd send it along.
---
 gcc/testsuite/gcc.dg/analyzer/pr104308.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/analyzer/pr104308.c 
b/gcc/testsuite/gcc.dg/analyzer/pr104308.c
index a3a0cbb7317..ae40e59c41c 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr104308.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr104308.c
@@ -8,12 +8,13 @@ int test_memmove_within_uninit (void)
 {
   char s[5]; /* { dg-message "region created on stack here" } */
   memmove(s, s + 1, 2); /* { dg-warning "use of uninitialized value" } */
-  return 0;
+  return s[0];
 }
 
 int test_memcpy_from_uninit (void)
 {
   char a1[5];
   char a2[5]; /* { dg-message "region created on stack here" } */
-  return (memcpy(a1, a2, 5) == a1); /* { dg-warning "use of uninitialized 
value" } */
+  memcpy(a1, a2, 5); /* { dg-warning "use of uninitialized value" } */
+  return a1[0];
 }
-- 
2.34.1

Reply via email to