Some subsurface notes from a week of diving

Lubomir I. Ivanov neolit123 at gmail.com
Mon Mar 17 14:57:05 PDT 2014


On 17 March 2014 23:50, Thiago Macieira <thiago at macieira.org> wrote:
> 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.
>

i see..so i guess it's right to optimize there since p does not point
at the top.

lubomir
--


More information about the subsurface mailing list