In a bit of serialization code for a project I\'m working on I have a type whose size is compiler dependent. In order to deal with this, I decided to use a template specializati
The template specializations in your example are functions with external linkage. The compiler cannot know that they won't be called from another translation unit.
On my g++ 4.7.2 Ubuntu system, placing the templates into an anonymous namespace and compiling with -O3
prevented the unused function from being generated.
Similarly, declaring the function template static
had the desired effect.