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 c++/108893] attribute access read_only
Date: Sun, 26 Feb 2023 00:01:27 +0000	[thread overview]
Message-ID: <bug-108893-4-5NVjEe0hQA@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108893-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #10 from Jonny Grant <jg at jguk dot org> ---
(In reply to Andrew Pinski from comment #9)
> (In reply to Jonny Grant from comment #8)
> > So the caveat is this issue (2). I can't use attribute nonnull due to these
> > optimizations that cannot be disabled.
> 
> But you declare that argument cannot be null. So why keep around a check for
> it being null. The nonnull attribute is basically saying there is a
> requirement for it being nonnull no matter what. It basically says if a null
> is passed undefined behavior happens.

My concern would be when building a library, the nullptr checks might be
removed by the optimizer, and then when linked a nullptr could slip through if
they called functions indirectly (ie. not via a header with the same attribute
nonnull)

I would rather avoid undefined behavior nullptr dereference SEGV, as safety
critical software. For instance such functions could check parameters and
return -1 if a nullptr is present. So application can handle it, log an issue
etc

So, I'm adding -fno-delete-null-pointer-checks to my builds as I didn't realise
that was on already in -O3.

  parent reply	other threads:[~2023-02-26  0:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 20:27 [Bug c++/108893] New: " jg at jguk dot org
2023-02-22 20:30 ` [Bug c++/108893] " pinskia at gcc dot gnu.org
2023-02-22 20:31 ` pinskia at gcc dot gnu.org
2023-02-22 20:33 ` pinskia at gcc dot gnu.org
2023-02-22 20:54 ` jg at jguk dot org
2023-02-24 23:42 ` jg at jguk dot org
2023-02-24 23:44 ` pinskia at gcc dot gnu.org
2023-02-24 23:47 ` pinskia at gcc dot gnu.org
2023-02-25 23:39 ` jg at jguk dot org
2023-02-25 23:47 ` pinskia at gcc dot gnu.org
2023-02-26  0:01 ` jg at jguk dot org [this message]
2023-02-26  0:03 ` 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-108893-4-5NVjEe0hQA@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).