[CXX-576] shared_buffer.h uses placement new without including <new> Created: 05/Apr/15  Updated: 06/Apr/15  Resolved: 06/Apr/15

Status: Closed
Project: C++ Driver
Component/s: Implementation
Affects Version/s: legacy-1.0.0
Fix Version/s: None

Type: Bug Priority: Trivial - P5
Reporter: Steve Hickman Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

mongo/util/shared_buffer.h uses a placement new on line 60. It does not include <new> prior to that. Nor does it use std:: as a prefix.

When including "mongo/client/dbclient.h", depending on other includes in the cpp, this results in the occasional compile error :

%MONGO_INCLUDE%\mongo/util/shared_buffer.h(60): error C2061: syntax error : identifier 'holderPrefixedData'



 Comments   
Comment by Andrew Morrow (Inactive) [ 06/Apr/15 ]

Thanks for providing the additional info.

I've taken a look at the C++ standard, and, if I've ready correctly, a new expression (which placement new is) does not require an inclusion of \<new\>.

Given that, I'm going to close this as works as designed, but please feel free to re-open if you have further issues along these lines.

Comment by Steve Hickman [ 05/Apr/15 ]

Apologies: Problem due to inclusion of debug version of new (see the code below) in my test program. Removing that code resolved the problem. No change needed to shared_buffer.h

// To detect memoryleak along with line number, added below lines of code
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

#ifdef _DEBUG
#define DEBUG_NEW new(NORMAL_BLOCK, __FILE, __LINE_)
#define new DEBUG_NEW
#endif

Generated at Wed Feb 07 21:59:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.