public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jg at jguk dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug analyzer/109266] Wanalyzer-null-dereference does not warn when struct is at null
Date: Sun, 26 Mar 2023 21:08:29 +0000	[thread overview]
Message-ID: <bug-109266-4-jidpeoGM9e@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109266-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109266

--- Comment #2 from Jonny Grant <jg at jguk dot org> ---
Thank you for your reply David. Your analyzer is very good already.

I played around a bit, a base of nullptr doesn't give a warning. But changing
to 0x10 does give array-bounds warning.
cc1plus: note: source object is likely at address zero
<source>:13:13: warning: array subscript 0 is outside array bounds of 'a_t [0]'
[-Warray-bounds=]

https://godbolt.org/z/PhhT48xxP

Found Andrew Pinski comment says 4096 is not accessible:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106699#c1

I wondered if you know how to turn on that "cc1plus: note: source object is
likely at address zero? It seems different from normal warnings.


It would be fantastic if there was a way for me to specify on the gcc command
line an address range I didn't want read and/or writable. That would be great
to get build warnings from those addresses if the compiler could see them being
accessed.

At the moment, I always need to use the JTAG debugger to set some hw
breakpoints on read from various addresses to catch those accesses (as they are
mapped to the interrupt vector from 0x0). On Windows I've had various crashes
where the access was address 0x10 so felt like that was probably a struct
offset too

I don't know very much about gcc internals. I did wonder if the analyzer can
see the base address of the struct being passed as 0x0 in the RTL file?
I tried -fdump-rtl-all but couldn't see the 0x0 address, or when I changed to
0x10 either

  parent reply	other threads:[~2023-03-26 21:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 22:17 [Bug analyzer/109266] New: " jg at jguk dot org
2023-03-26 14:58 ` [Bug analyzer/109266] " dmalcolm at gcc dot gnu.org
2023-03-26 21:08 ` jg at jguk dot org [this message]
2023-03-27 23:14 ` dmalcolm at gcc dot gnu.org
2023-03-27 23:22 ` dmalcolm at gcc dot gnu.org
2023-03-31 21:30 ` jg at jguk dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109266-4-jidpeoGM9e@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).