From eb37ea529745c38dcf86c3cdbedb66df69ea9e35 Mon Sep 17 00:00:00 2001 From: David Malcolm <dmalcolm@redhat.com> Date: Mon, 19 Feb 2024 18:07:59 -0500 Subject: [PATCH] analyzer, testsuite: add regression test [PR110520] gcc/testsuite/ChangeLog: PR analyzer/110520 * c-c++-common/analyzer/null-deref-pr110520.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com> --- gcc/testsuite/c-c++-common/analyzer/null-deref-pr110520.c | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/analyzer/null-deref-pr110520.c diff --git a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr110520.c b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr110520.c new file mode 100644 index 000000000000..b57027689eed --- /dev/null +++ b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr110520.c @@ -0,0 +1,8 @@ +#include "analyzer-decls.h" + +int main(void) { + char buf[] = "0"; + int *ptr = (int *)(__builtin_strlen(buf) - 1); + __analyzer_eval((__builtin_strlen(buf)) == 1); /* { dg-warning "TRUE" } */ + *ptr = 10086; /* { dg-warning "dereference of NULL 'ptr'" } */ +} -- GitLab