This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can offsetting a non-null pointer result in a null one?


On Wed, Aug 15, 2018 at 7:44 AM Liu Hao <lh_mouse@126.com> wrote:
>
> 在 2018-08-15 12:48, Jeff Law 写道:
> > I just don't think anyone's ever bothered to catch this case.  I believe
> > there is a BZ which touches on this issue.
> >
>
> Yes, here it is: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78655
>
> This PR uses a placement new as the example, which in GCC 8 assumes the
> pointer argument to `operator new()` is never null. But for a general
> case it is still not fixed.
>
> So it looks like nobody has been working on this. I will just fix my
> code then.

Btw, I can't find wording in the standards that nullptr + 1 is
invoking undefined behavior,
that is, that pointer arithmetic is only allowed on pointers pointing
to a valid object.
Any specific pointers?

Thanks,
Richard.

> > Jeff
> >
>
>
> --
> Best regards,
> LH_Mouse
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]