new operator placement function not exist

Asked by tony yu

I used g++-4.8 toolchain for a while. everything works great, until i need to new opeartor placement write function such as

new (&boardObj.stBrd) classTypeX {}; // won't do allocate, simply initialize the object. need to use this because of existance of virtual function.
the error message is
error: no matching function for call to 'operator new(sizetype, classTypeX*).
I searched the web. some site said that new(size_t, void*) is not implemented or so.

My compile option is
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mlittle-endian -mthumb -mthumb-interwork -fno-common -fno-builtin -std=c++11
The placement initialization is needed for some memory management function.
Is there any solution for this?

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
tony yu
Solved:
Last query:
Last reply:
Revision history for this message
Joey Ye (jinyun-ye) said :
#1

Hi, Tony,

This issue does not seem to be a bug, nor is it specific to this tool release. I don't have an answer now. I would suggest you send this question to <email address hidden> instead, where the general GCC usage questions were asked and answered.

Thanks,
Joey

Revision history for this message
tony yu (yu-tony) said :
#2

Hi, Joey,
Thanks for your reply. the feature has been in the other OS distribution of gcc. The "new operator" function work quite will on ubuntu g++ 4.8 and 5.0, it's in gcc/g++. I agree with you that I don't think it's a bug.

I suspected the issue is either
1. different compilation/config of libstdc++, so the feature is not in this tool chain.
2. it's not implemented because of the reduced set of the libraries in this tool chain.
3. the feature exist in this tool chain compilation, I just use wrong option or library or whatever.

That's the reason I post question here.
the specific feature is "new" operator 'void* operator new (std::size_t size, void* ptr)'

Regards,
Tony

Revision history for this message
Joey Ye (jinyun-ye) said :
#3

Tony,

Thanks for the further clarification. Now can you please provide a workable test case for us to easier reproduce it?

Joey

Revision history for this message
tony yu (yu-tony) said :
#4

HI, Joey,

First, thank your for your help and time.
I finally found the issue during the preparation of the test case.
The problem is that c++/g++ only have build in new(size_t) operator. To have the new placement operator, system include <new> is required.
When I test in other distribution, I include <iostream> and that internally include <new>, So the test case work on other distribution instead of embedded environment.

Regards,
Tony