cppcheck sept 18 redux
shacklein at gmail.com
Tue Sep 22 09:53:08 CDT 2009
2009/9/23 Chris Robinson <chris.kcat at gmail.com>:
> On Tuesday 22 September 2009 12:32:35 am Mike Kaplinskiy wrote:
>> It actually does not dereference anything.
> Does the C standard specify that taking the address of a struct member being
> dereferenced doesn't actually cause a dereference, instead just offsetting?
> Doing foo-> is identical to (*foo)., so dmW->dmFormName is the same as
> &(*dmW).dmFormName, which does technically cause a dereference, followed by
> taking the address of the field.
> However, since GCC will remove deadcode and it's simple to see the dereference
> isn't needed, it just optimizes it away. I wouldn't even be surprised if this
> behavior is guaranteed by GCC with no optimizations enabled.. but I'm not so
> sure that it's guaranteed by the C standard. Is it?
Worth trying my sample code on non-GCC compilers then:
struct foo *bar=NULL;
Is there a reason why sizeof() magic can't be used instead of FIELD_OFFSET? :)
More information about the wine-devel