Some subsurface notes from a week of diving
Thiago Macieira
thiago at macieira.org
Mon Mar 17 14:50:24 PDT 2014
Em seg 17 mar 2014, às 22:26:19, Lubomir I. Ivanov escreveu:
> > if (!p)
> > return -1;
> > return *p;
> >
> > }
> >
> > Clang 3.4 removes the check for !p. ICC 14.0 and GCC 4.9 don't.
>
> quite bogus; i don't see why clang removes the check for !p.
The only way for p to be null is if d was -offsetof(d, p) (that is, -0x4).
The compiler is, in my opinion, quite right to assume that the address of a
member of an object is not null. A pointer to the top of the object might be,
but it makes no sense for an object to roll over the top of the memory and
overflow.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
More information about the subsurface
mailing list