[gcc r11-2695] analyzer: add regression test [PR96598]

David Malcolm dmalcolm@gcc.gnu.org
Thu Aug 13 23:09:03 GMT 2020


https://gcc.gnu.org/g:2ec32ddf822887cddc8910ed30dc105890def4ee

commit r11-2695-g2ec32ddf822887cddc8910ed30dc105890def4ee
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Thu Aug 13 15:11:10 2020 -0400

    analyzer: add regression test [PR96598]
    
    PR analyzer/96598 reports that -fanalyzer issues a false
      warning: use of NULL 'str' where non-null expected
    with gcc 10.2 when used with -fsanitize=undefined.
    
    This was fixed by g:808f4dfeb3a95f50f15e71148e5c1067f90a126d.
    
    gcc/testsuite/ChangeLog:
            PR analyzer/96598
            * gcc.dg/analyzer/pr96598.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/analyzer/pr96598.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/analyzer/pr96598.c b/gcc/testsuite/gcc.dg/analyzer/pr96598.c
new file mode 100644
index 00000000000..b4354cd3394
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr96598.c
@@ -0,0 +1,26 @@
+/* { dg-additional-options "-O0 -fsanitize=undefined" } */
+
+extern char *foo (char *dest, const char *src)
+  __attribute__ ((__nonnull__ (1, 2)));
+
+unsigned bar(const char *str)
+  __attribute__ ((__nonnull__ ()));
+
+unsigned test(const char *str, unsigned **pv)
+  __attribute__ ((__nonnull__ ()));
+
+unsigned test(const char* str, unsigned **pv)
+{
+  char buffer[130];
+
+  *pv = 0;
+
+  foo(buffer, str);
+  if (bar(buffer))
+    {
+      const char *ptr = 0;
+      foo(buffer, str);
+      return bar(buffer);
+    }
+  return 0;
+}


More information about the Gcc-cvs mailing list