Optimization question

Nikolaus Dunn nikdunn1979@gmail.com
Tue Sep 27 15:01:00 GMT 2016


Hi guys,

I've run into an issue where turning on compiler optimization using -O1 
or higher causes an issue in my program. Specifically, I am replacing 
the new and delete operators globally to perform some real time 
allocation tracking. When I compile with -O1 or -O2, my implementation 
of new is not being called by STL classes, via the std::allocator. My 
version of delete IS being called.

I realize I may be doing something wrong and I've read many posts from 
people saying not to replace new and delete, but I'm hacking on a 15 
year old baseline. We've just stepped up to GCC 5.3.0 and are compiling 
with the -std=c++14 option (to give a little context). I'm also 
compiling using MinGW, but I'm figuring MinGW would be using the same 
optimization logic at the compiler level as pure GCC.

Before I go through by hand and try to determine which optimization 
seems to be causing the problem, does anyone have a suggestion as to the 
culprit? Am I doing something essentially wrong? I'd happily post an 
example program, but I'm hoping my question is general enough in nature 
to warrant an easy response.

Thanks,

Nik



More information about the Gcc mailing list