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.