Optimization question

Florian Weimer fw@deneb.enyo.de
Tue Sep 27 15:20:00 GMT 2016

* Nikolaus Dunn:

> 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.

This matter is appropriate for the gcc-help list, redirecting there.

> 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.

It's unclear whether this is an optimization issue, or a different
build issue.  We can't really comment on what's going wrong until you
have actual source code to show, I'm afraid.

Do you define your version of the global operators new and delete in
the same translation unit?

More information about the Gcc-help mailing list