This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Optimization question


On 27 September 2016 at 19:32, Florian Weimer wrote:
> * Nikolaus Dunn:
>
>> std::ostringstream however does not call my new OR delete with no
>> optimization. With -O2, it calls only my delete.
>>
>> If I do not attempt to wrap malloc and free, I get the same
>> result. std::vector calls my new and delete, ostringstream calls
>> neither.
>>
>> The command line I used to compile it is:
>> g++ -g -O2 --std=c++14 -Wl,-wrap,malloc -Wl,-wrap,free Test.c -o test.exe
>
> “-Wl,-wrap,malloc -Wl,-wrap,free” is only effective for newly-compiled
> code.  Your example probably uses some template instantiations which
> are supplied by libstdc++, and these will keep calling the unwrapped
> malloc/free implementations.

Right, std::stringstream doesn't allocate any memory itself, but
std::string does, and that is instantiated in the libstdc++.so
library.

> I don't know if there are mechanisms on mingw which are comparable to
> ELF symbol interposition.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]