1. 4
  1.  

  2. 1

    This page is old and has some inaccuracies (I’ve come across it before so I remember). A quick flick through and “Casting from a union (2)” looks wrong; it says that the warning generated from the sample code is a false positive, but in fact it’s not (the compiled code probably ends doing what was intended in most cases, but the GCC documentation is pretty clear that this is not supported; see https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Optimize-Options.html under the “-fstrict-aliasing” option).

    Also, slightly more nit-picky, but:

    In other words, casting from a pointer of one type to pointer of an unrelated type through a char* is undefined.

    I’m pretty sure this is not undefined behaviour, just an unspecified pointer value. De-referencing the resulting pointer could well invoke undefined behavior, because there’s no guarantee that it points at an object (and if it does it may point at the wrong type of object, making the de-reference a violation of strict aliasing).