[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/sys/kern
On Jan 31, 2012, at 3:53 PM, Alexander Nasonov wrote:
> David Laight wrote:
>> I don't believe there is a problem using m, just m[non-constant-expr].
> Practically speaking, m is not a problem but the standard says
> ... to the structure member (designated by member-designator), ...
>> OTOH 'sizeof (s *)0->m' might be deemed invalid (because it has
>> an inferred dereference of NULL.
> Oh yes. I can change it to:
> extern void *foo(void);
> and then sizeof(((s *)foo())->m) but NULL should work too.
> So, if we reached a consensus on this, where should I add the macro?
There's no NULL dereference, so it is fine (completely standards conforming).
The sizeof operator is a compile time construct that evaluates its argument for
its type only, so no dereference is happening, so any value for the pointer is
OK. In the absence of a local variable, 0 is just as valid as anything else.
Main Index |
Thread Index |