-
Notifications
You must be signed in to change notification settings - Fork 533
Open
Description
Hello, how are you?
I think I have found an interesting bug.
I am trying to use the placement new to construct in a previously allocated buffer.
However the macro #define new new(__FILE__, __LINE__)
, defined in MemoryLeakDetectorNewMacros.h, seems to break the placement new.
/* file.cpp */
void f()
{
// Buffer
unsigned char buff[100];
// Placement new
new (buff) int(0);
}
Compiling the code above gives the following error when including MemoryLeakDetectorNewMacros.h.
src/file.cpp:7:10: error: ‘buff’ does not name a type
4 | new (buff) int(0);
| ^~~~
There is a workaround, which consists of #undef the macro before the placement new.
/* file.cpp */
void f()
{
// Buffer
unsigned char buff[100];
// Workaround
#ifdef new
#undef new
#endif
// Placement new
new (buff) int(0);
}
I hope that we can fix this, since the placement new is important on embedded systems.
If there are any questions, just let me know.
Best regards,
Metadata
Metadata
Assignees
Labels
No labels