Home Dashboard Directory Help

Cannot define placement new in any project where another file #includes <new> directly or indirectly by David Librik


 as By Design Help for as By Design

Sign in
to vote
Type: Bug
ID: 768788
Opened: 10/25/2012 10:24:07 PM
Access Restriction: Public
User(s) can reproduce this bug


If you have a C++ file in your program which defines a placement new function, and another C++ file which #includes <new> either directly or indirectly (i.e. a different C++ header that happens to #include <new>), you will get multiple LNK2005 errors.

This only happens with the Visual Studio 2012 toolchain. The older toolchains (Visual Studio 2008, 2010) compile and link it just fine.
Sign in to post a comment.
Posted by Microsoft on 12/5/2013 at 3:44 PM

Thanks for reporting this issue. I've resolved it as By Design because the C++ Standard forbids users from defining "True Placement New" when their program includes any part of the C++ Standard Library. The Standardese is C++11 [new.delete.placement]/1: "These functions are reserved, a C++ program may not define functions that displace the versions in the Standard C++ library [...] void* operator new(std::size_t size, void* ptr) noexcept;"

VS 2012 began rejecting this due to internal STL changes.

Stephan T. Lavavej
Senior Developer - Visual C++ Libraries
Posted by David Librik on 10/20/2013 at 3:13 AM
This is still broken in Visual C++ 2013.
Posted by Microsoft on 10/26/2012 at 1:34 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 10/25/2012 at 10:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
placement-new-error.zip 10/25/2012 325 bytes
placement-new-error.zip 10/25/2012 325 bytes