public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amacleod at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/78655] gcc doesn't exploit the fact that the result of pointer addition can not be nullptr
Date: Fri, 13 Nov 2020 14:46:52 +0000 [thread overview]
Message-ID: <bug-78655-4-klp8BaqAzs@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-78655-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78655
Andrew Macleod <amacleod at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amacleod at redhat dot com
--- Comment #9 from Andrew Macleod <amacleod at redhat dot com> ---
Created attachment 49556
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49556&action=edit
testcase
(In reply to Marc Glisse from comment #8)
> (just to put this somewhere)
> We have multiple ways of doing pointer arithmetic in gcc. After the recent
> patch, we know that g returns nonnull, but we don't know it for f.
>
> struct A{int a,b;};
> int*f(A*p){return&p->b;}
> int*g(A*p){return(int*)p+1;}
I tweaked this and made a testcase out of it. I think it is correct?
We do know that both f and g are non-null now, as well as checks for when
returning p->a for 0 offsets... So I think this is covered?
Furthermore,
bool f(int* a)
{
bool x = a == nullptr;
a += 10;
return x;
}
turns into
a_1(D) int * VARYING
<bb 2> :
x_2 = a_1(D) == 0B;
a_3 = a_1(D) + 40;
return x_2;
a_3 : int * [1B, +INF]
And from there, I don't see any way to determine that 'a_1' can't be nullptr.
we've lost whatever context nullptr is suppose to provide... its just a 0 now.
All we can see is that a_3 is non-null.
next parent reply other threads:[~2020-11-13 14:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-78655-4@http.gcc.gnu.org/bugzilla/>
2020-11-13 14:46 ` amacleod at redhat dot com [this message]
2022-01-12 16:33 ` amacleod at redhat dot com
2022-01-12 19:21 ` law at gcc dot gnu.org
2022-01-13 7:20 ` rguenth at gcc dot gnu.org
2022-01-13 13:43 ` amacleod at redhat dot com
2022-11-16 15:46 ` amacleod at redhat dot com
2022-11-17 7:47 ` rguenther at suse dot de
2022-11-17 14:35 ` amacleod at redhat dot com
2022-11-17 14:47 ` rguenther at suse dot de
2022-11-17 15:47 ` amacleod at redhat dot com
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-78655-4-klp8BaqAzs@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).