Strict aliasing rule strikes back

Marc Lehmann schmorp at
Sat May 23 12:58:28 CEST 2015

On Fri, May 22, 2015 at 05:20:39PM -0700, Andrey Pokrovskiy <wonder.mice at> wrote:
> > the additional void * cast is there to confuse some compilers
> > into not emitting a warning, but is generally not very effective.
> Reminds me of "security through obscurity".

Ugh, it shouldn't, because that would be a phenomenally poor analogy
- there is no loss nor gain from trying to avoid a compiler warning
regarding correctness (the semantics of the code don't change due to the
extra cast, the same is true for using extra ()'s to silence warnings),
while using obscurity for security in fact disables your security.

The analogy would hold if the extra cast would silence the compiler while
also introducing or keeping an aliasing violation - you'd gain silence
that makes you feel safe, but in fact it's completely unsafe.

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list