public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jamborm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/108517] [11/12/13 Regression] std::sort of empty range yield "warning: 'this' pointer is null"
Date: Wed, 15 Feb 2023 15:28:47 +0000	[thread overview]
Message-ID: <bug-108517-4-ZggH52oVGM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108517-4@http.gcc.gnu.org/bugzilla/>

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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #8 from Martin Jambor <jamborm at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #6)
> Somehow this constprop function is kept in the IL but not really called by
> anything once IPA passes are done.

This is discovered only when performing inlining on GIMPLE bodies, I
guess during folding of the conditions.  At this point, with LTO, the
constprop functions could theoretically be in another partition so
generally it is too late to remove them as unreachable.

(In reply to Jakub Jelinek from comment #7)
> Or perhaps when considering the constprop see that for __first_5(D) being 0B
> there would be pointer arithmetics on NULL (the __first_5(D) p+ 16) and so
> would invoke UB or likely invoke UB and so not worth constant propagation.

Only when unguarded.  Being able to eliminate these when they are
guarded by a NULL check is something that IPA-CP should do.  And NULL
checks can be non-obvious at IPA time, in this case this is
essentially done by the check that

  if (__first_4(D) != __last_5(D))

where we manage to prove that __first is zero but __last can be either
zero or zero pointer_plus 16 and therefore we fail to propagate (for
all contexts).

I'm afraid I don't have any good ideas that might not lead to adverse
effects in other situations.  Perhaps we could specifically track such
comparisons in a bitmap and then do some "likely invalid pointer"
propagation for pointer arithmetics and then avoid cloning for zero
value in presence of such comparisons...

  parent reply	other threads:[~2023-02-15 15:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 12:01 [Bug libstdc++/108517] New: " hanicka at hanicka dot net
2023-01-24 12:33 ` [Bug libstdc++/108517] " redi at gcc dot gnu.org
2023-01-24 12:35 ` redi at gcc dot gnu.org
2023-01-24 12:37 ` [Bug c++/108517] " redi at gcc dot gnu.org
2023-01-24 12:41 ` redi at gcc dot gnu.org
2023-01-24 13:01 ` [Bug c++/108517] [11/12/13 Regression] " redi at gcc dot gnu.org
2023-01-24 13:07 ` rguenth at gcc dot gnu.org
2023-02-01 12:32 ` jakub at gcc dot gnu.org
2023-02-01 12:40 ` jakub at gcc dot gnu.org
2023-02-15 15:28 ` jamborm at gcc dot gnu.org [this message]
2023-02-21 12:59 ` rguenth at gcc dot gnu.org
2023-05-29 10:07 ` [Bug c++/108517] [11/12/13/14 " jakub at gcc dot gnu.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-108517-4-ZggH52oVGM@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).