I have this method in my C++ program, in Visual Studio 2012, standard compiler:
bool FPS::frameRenderingQueued(const Ogre::FrameEvent &evt) {
bool result = BaseApplication::frameRenderingQueued(evt);
if (!result) {
Ogre::LogManager::getSingleton().logMessage("Exiting, result of frame rendereing queued: " + result);
return result;
}
for (int x = 0; x < 20; x++) {
for (int z = 0; z < 20; z++) {
robotAnimation[x][z]->addTime(evt.timeSinceLastFrame);
tileSceneNode[x][z]->translate(tileSceneNode[x][z]->getOrientation() * Ogre::Vector3::UNIT_X * 35.0f * evt.timeSinceLastFrame);
}
}
}
How could it compile without giving any errors? I mind you that the result cannot be predictable.
When I ran it, this happened: The function itself returned false
(as Ogre shuts down if frameRenderingQueued()
returns false
. However the branch if (!result) { ... }
has never been reached. So the behaviour was unpredictable.
Later when I added return true;
at the end of the function, everything was working as expected.
So how could this broken method compile just fine?