[Vm-dev] Question about pointer comparison

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Wed Mar 25 13:14:00 UTC 2015


2015-03-25 12:52 GMT+01:00 David T. Lewis <lewis at mail.msen.com>:

>
> On Tue, Mar 24, 2015 at 10:32:32PM -0700, Eliot Miranda wrote:
> >
> > On Tue, Mar 24, 2015 at 8:33 PM, Nicolas Cellier <
> > nicolas.cellier.aka.nice at gmail.com> wrote:
> >
> > >
> > > Hi,
> > >
> > > in checkStackIntegrity, there is a comparison of char *
> > >
> > > theSP <= frameRcvrOffset
> > >
> > > Is it OK, or should we better use oop:isLessThanOrEqualTo: ?
> > >
> >
> > Providing that both are typed as non-void pointers to the same type this
> > will work.  oop:isLessThanOrEqualTo: is there for comparing sqInt values
> > (i.e. oops) as this is a signed type and oop:isLessThanOrEqualTo: forces
> an
> > unsigned comparison.
>
> Agreed, both variables are (char *), so the pointer comparison is OK as
> written.
>
> Dave
>
>
OK, thanks both, I see it better now.
It's specified in ISO/IEC 9899:TC3, 6.5.8 rule 5 (relational operators)
(draft available at
http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf)

Strictly speaking, behavior is undefined when comparing two pointers that
do not point to the same aggregate or to the same array, but i guess we can
live with that.

Cheers

Nicolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20150325/584b3d32/attachment.htm


More information about the Vm-dev mailing list