working part of [ticket-01a2f3a346]
(still don't understand, but somehow it doesn't work with msvc)