cvs builds of gcc give the following warnings for the LDAP SDK (ldapcsdk_50_client_branch): memcache.c:1416: warning: dereferencing type-punned pointer will break strict-aliasing rules memcache.c:1446: warning: dereferencing type-punned pointer will break strict-aliasing rules memcache.c:1520: warning: dereferencing type-punned pointer will break strict-aliasing rules Since strict aliasing is now enabled by default for gcc with -O2, we should fix this. Strict aliasing bugs can cause all sorts of weird problems; for some background see http://gcc.gnu.org/ml/gcc/1999-08n/msg00646.html . It looks like the fix in this case is to use an explicit temporary void* pointer.
Comment on attachment 103565 [details] [diff] [review] proposed patch r=mcs. Intersting. Although I did not write it, I am not sure how the existing code in libldap/memcache.c could cause any real problems. But I don't write compilers for a living either.
I think in this case the warnings are harmless. I don't see the potential for any problems with aliasing unless a struct is written to and read as two different (unrelated) pointer types within the same function.
Fix committed to the trunk: mozilla/directory/c-sdk/ldap/libraries/libldap/memcache.c new revision: 5.2; previous revision: 5.1 Fix bug # 175727 - strict aliasing bugs in LDAP C SDK. Avoid casts like (void**)&pRes; use temporary local variables instead. Do we also want this fixed on ldapcsdk_50_client_branch right away?
There's no huge rush. All we're really doing here is working around the warnings; I don't think this is causing any actual bugs.
Marking bug as fixed. We will pick this up in the Mozilla client builds when those builds move to an update LDAP C SDK branch.
Spam for bug 129472