I'm building an event system which mimics to some extent how Qt's signal/slots work.
I make connections which looks something like this:
EventHandler::connect(&EventDispatcher::getInstance(), &EventDispatcher::mouseClicked, (Button*)this, &Button::on_mouseClicked);
The mouseClicked is a member function in EventDispatcher with an empty body and is merely used to signal which event was triggered:
void mouseClicked(float /*x*/, float /*y*/) {}
The issue I'm having is that visual studio seems to optimize all member functions with the same parameter list and body to be equal to each other. This is not an issue in Debug mode, nor with Clang or GCC (in Linux and OS X).
In short:
void mouseClicked(float /*x*/, float /*y*/) {}
void windowResized(float /*w*/, float /*h*/) {}
EventDispatcher::*func1(float, float) = &EventDispatcher::mouseClicked;
EventDispatcher::*func2(float, float) = &EventDispatcher::windowResized;
assert(func1 != func2); // <- This only fails in Visual studio Release mode
Temporary fix
As a quick fix I added a dummy function body (which really makes me cringe, but I'm crunching towards a release) that just logs some crap. Since the function isn't ever called, that shouldn't affect performance.
I'd love to hear alternative solutions.