free hit counter

Tuesday, February 26, 2008

Type punning

After seeing the warning:
"dereferencing type-punned pointer will break strict-aliasing rules"
I got curious: What the hell is type punning?

Type Punning (from wikipedia)
In computer science, type punning is a common term for any programming technique that subverts or circumvents the type system of a programming language in order to achieve an effect that would be difficult or impossible to achieve within the bounds of the formal language.

Turns out I've been doing these kinds of hacks for ages, but didn't know there was a formal name for them! With default flags GCC does some optimizations that rely on strict aliasing of variables that type punning may break.



Post a Comment

<< Home