Not good advice. This violates the strict aliasing rules, and is not guaranteed to give the results you might expect.
Strict aliasing is off by default in MSVC, which is why he might get the results he expected here, but bear in mind that it's on by default when optimizations are enabled in GCC.
As a general rule when blogging about some programming language features - follow the language specification and not some implementation specific behavior.
1 comment
[ 2.8 ms ] story [ 27.7 ms ] threadStrict aliasing is off by default in MSVC, which is why he might get the results he expected here, but bear in mind that it's on by default when optimizations are enabled in GCC.
As a general rule when blogging about some programming language features - follow the language specification and not some implementation specific behavior.