I think the first example is sorta invalid because there's a typo:
return *(uint32_t*)f;
should read as: return *(uint32_t*)(&f);
With this change, the code indeed compiles fine (with g++ 5.3.1; not sure of 5.3.0, which the author used)