Home Dashboard Directory Help
Search

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


Status: 

Closed
 as By Design Help for as By Design


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

Description

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.
Details
Sign in to post a comment.
Posted by Microsoft on 12/5/2013 at 3:44 PM
Hi,

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 18.6.1.3 [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
stl@microsoft.com
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