Optimization question

Jonathan Wakely jwakely.gcc@gmail.com
Wed Sep 28 10:13:00 GMT 2016

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

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

More information about the Gcc-help mailing list