Index: pthread/tss.hpp =================================================================== --- pthread/tss.hpp (revision 45823) +++ pthread/tss.hpp (working copy) @@ -56,7 +56,15 @@ } }; + struct noop_cleanup_function: + detail::tss_cleanup_function + { + void operator()(void*) + { + } + }; + boost::shared_ptr cleanup; public: @@ -64,7 +72,9 @@ cleanup(new delete_data) {} explicit thread_specific_ptr(void (*func_)(T*)): - cleanup(new run_custom_cleanup_function(func_)) + cleanup(func_ ? + static_cast(new run_custom_cleanup_function(func_)) : + static_cast(new noop_cleanup_function)) {} ~thread_specific_ptr() { Index: win32/tss.hpp =================================================================== --- win32/tss.hpp (revision 45823) +++ win32/tss.hpp (working copy) @@ -51,7 +51,7 @@ void operator()(void* data) { - cleanup_function(static_cast(data)); + if (cleanup_function) cleanup_function(static_cast(data)); } };