id summary reporter owner description type status milestone component version severity resolution keywords cc 3875 make_shared, allocate_shared fail compile with aligned objects in msvc Dieter Van Wassenhove Peter Dimov "When using make_shared or allocate_shared with a type that requires alignment, the code fails to compile in MSVC with an error similar to the following: error C2719: 'd': formal parameter with __declspec(align('64')) won't be aligned 1> d:\projects\boost_1_41_0\boost\smart_ptr\detail\shared_count.hpp(124) : see reference to class template instantiation 'boost::detail::sp_counted_impl_pd' being compiled ............ (instantiation stack) Now, there is code in boost that looks like it wants to detect object alignment, but some how is not compatible with the MS compiler. There are various reports online indicating this is more of an issue with MS. However, when I provide my own custom allocator to boost::allocate_shared, I'd expect the issue to go away since both creation and destruction of the type would use my allocator and therefore not be concerned with the type's actual alignment any longer. I was hoping to work around this issue by providing an alignment sensitive allocator but I still get the same problem. It seems that the internal deleter is too overzealous in this situation and should be delegate the destruction of the object directly to the allocator. //repro: I didn't include a custom allocator as it seems fairly //straight forward to use any allocator and ensure that it's used //for destruction. #include #include struct __declspec(align(64)) MyClass { int x; float y; unsigned int z; }; void main() { boost::shared_ptr ptr = boost::make_shared(); ptr->x = 6; }" Bugs closed Boost 1.42.0 smart_ptr Boost 1.41.0 Problem fixed allocate_shared msvc alignment