public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-9075] analyzer, testsuite: add regression test [PR110520]
@ 2024-02-19 23:10 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2024-02-19 23:10 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:eb37ea529745c38dcf86c3cdbedb66df69ea9e35

commit r14-9075-geb37ea529745c38dcf86c3cdbedb66df69ea9e35
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Mon Feb 19 18:07:59 2024 -0500

    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>

Diff:
---
 gcc/testsuite/c-c++-common/analyzer/null-deref-pr110520.c | 8 ++++++++
 1 file changed, 8 insertions(+)

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'" } */
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-19 23:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 23:10 [gcc r14-9075] analyzer, testsuite: add regression test [PR110520] David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).