http://cppcheck.sourceforge.net/
It analyses C++ sourcecode and gives advices on several stuff that compilers often don't recognize (performance, never used variables, variable scope optimizations, not initialized variables, const correctness, pass-by-reference, detecting obsolete functions, ...).
Here is the output it gave me for the current OD source, I'm going to fix some of them.
- {l Code}: {l Select All Code}
[\include\Socket.h:53]: (performance) Function parameter 'host' should be passed by reference.
[\include\GameMap.h:260]: (information) Technically the member function 'AstarEntry::fCost' can be const.
[\include\ExampleApplication.h:73]: (warning) Member variable 'ExampleApplication::mCamera' is not initialised in the constructor.
[\include\ExampleApplication.h:73]: (warning) Member variable 'ExampleApplication::mWindow' is not initialised in the constructor.
[\include\ProtectedObject.h:36]: (warning) Member variable 'ProtectedObject<unsignedint>::object' is not initialised in the constructor.
[\include\ProtectedObject.h:36]: (warning) Member variable 'ProtectedObject<long>::object' is not initialised in the constructor.
[\src\Creature.cpp:2281]: (Stil) Variable 'myTile' is assigned a value that is never used
[\src\Creature.cpp:533]: (information) The scope of the variable diceRoll can be reduced
[\src\Creature.cpp:534]: (information) The scope of the variable tempDouble can be reduced
[\src\Creature.cpp:31]: (warning) Member variable 'Creature::color' is not initialised in the constructor.
[\src\Creature.cpp:31]: (warning) Member variable 'Creature::previousPositionTile' is not initialised in the constructor.
[\src\CreatureClass.cpp:3]: (warning) Member variable 'CreatureClass::bedDim1' is not initialised in the constructor.
[\src\CreatureClass.cpp:3]: (warning) Member variable 'CreatureClass::bedDim2' is not initialised in the constructor.
[\src\CreatureClass.cpp:3]: (warning) Member variable 'CreatureClass::coefficientHumans' is not initialised in the constructor.
[\src\CreatureClass.cpp:3]: (warning) Member variable 'CreatureClass::coefficientCorpars' is not initialised in the constructor.
[\src\CreatureClass.cpp:3]: (warning) Member variable 'CreatureClass::coefficientUndead' is not initialised in the constructor.
[\src\CreatureClass.cpp:3]: (warning) Member variable 'CreatureClass::coefficientConstructs' is not initialised in the constructor.
[\src\CreatureClass.cpp:3]: (warning) Member variable 'CreatureClass::coefficientDenizens' is not initialised in the constructor.
[\src\CreatureClass.cpp:3]: (warning) Member variable 'CreatureClass::coefficientAltruism' is not initialised in the constructor.
[\src\CreatureClass.cpp:3]: (warning) Member variable 'CreatureClass::coefficientOrder' is not initialised in the constructor.
[\src\CreatureClass.cpp:3]: (warning) Member variable 'CreatureClass::coefficientPeace' is not initialised in the constructor.
[\src\CreatureClass.cpp:101] -> [\include\CreatureClass.h:39]: (information) Technically the member function 'CreatureClass::isWorker' can be const.
[\src\ExampleFrameListener.cpp:253]: (Stil) Variable 'depth' is not assigned a value
[\src\ExampleFrameListener.cpp:254]: (Stil) Variable 'left' is not assigned a value
[\src\ExampleFrameListener.cpp:494]: (Stil) Variable 'releaseRenderQueueBarrier' is assigned a value that is never used
[\src\ExampleFrameListener.cpp:2726]: (information) The scope of the variable tempR can be reduced
[\src\ExampleFrameListener.cpp:2726]: (information) The scope of the variable tempG can be reduced
[\src\ExampleFrameListener.cpp:2726]: (information) The scope of the variable tempB can be reduced
[\src\ExampleFrameListener.cpp:1465]: (Stil) Found obsolete function 'usleep'. It is recommended that new applications use the 'nanosleep' or 'setitimer' function
[\src\GameMap.cpp:207]: (Stil) Variable 'allNeighborsSameColor' is assigned a value that is never used
[\src\GameMap.cpp:2466]: (information) The scope of the variable tempUnsigned can be reduced
[\src\GameMap.cpp:2496]: (information) The scope of the variable tempUnsigned can be reduced
[\src\GameMap.cpp:31]: (warning) Member variable 'GameMap::me' is not initialised in the constructor.
[\src\GameMap.cpp:31]: (warning) Member variable 'GameMap::miscUpkeepTime' is not initialised in the constructor.
[\src\GameMap.cpp:31]: (warning) Member variable 'GameMap::creatureTurnsTime' is not initialised in the constructor.
[\src\Goal.cpp:28] -> [\include\Goal.h:35]: (information) Technically the member function 'Goal::getName' can be const.
[\src\MapLight.cpp:29]: (warning) Member variable 'MapLight::ogreEntityVisualIndicatorExists' is not initialised in the constructor.
[\src\RadialVector2.cpp:43] -> [\include\RadialVector2.h:15]: (information) Technically the member function 'RadialVector2::directionIsBetween' can be const.
[\src\RenderRequest.cpp:3]: (warning) Member variable 'RenderRequest::turnNumber' is not initialised in the constructor.
[\src\RenderRequest.cpp:3]: (warning) Member variable 'RenderRequest::b' is not initialised in the constructor.
[\src\Room.cpp:15]: (warning) Member variable 'Room::type' is not initialised in the constructor.
[\src\Room.cpp:340] -> [\include\Room.h:52]: (information) Technically the member function 'Room::getType' can be const.
[\src\RoomObject.cpp:29] -> [\include\RoomObject.h:18]: (information) Technically the member function 'RoomObject::getMeshName' can be const.
[\src\RoomPortal.cpp:15]: (warning) Member variable 'RoomPortal::xCenter' is not initialised in the constructor.
[\src\RoomPortal.cpp:15]: (warning) Member variable 'RoomPortal::yCenter' is not initialised in the constructor.
[\src\RoomQuarters.cpp:123]: (information) The scope of the variable xDim can be reduced
[\src\RoomQuarters.cpp:123]: (information) The scope of the variable yDim can be reduced
[\src\RoomQuarters.cpp:123]: (information) The scope of the variable rotationAngle can be reduced
[\src\RoomTreasury.cpp:143] -> [\include\RoomTreasury.h:30]: (information) Technically the member function 'RoomTreasury::getTreasuryTileFullness' can be const.
[\src\Seat.cpp:4]: (warning) Member variable 'Seat::color' is not initialised in the constructor.
[\src\Seat.cpp:4]: (warning) Member variable 'Seat::startingX' is not initialised in the constructor.
[\src\Seat.cpp:4]: (warning) Member variable 'Seat::startingY' is not initialised in the constructor.
[\src\Seat.cpp:146] -> [\include\Seat.h:37]: (information) Technically the member function 'Seat::rawGetNumClaimedTiles' can be const.
[\src\Server.cpp:200]: (Stil) Found obsolete function 'usleep'. It is recommended that new applications use the 'nanosleep' or 'setitimer' function
[\src\Socket.cpp:102]: (performance) Function parameter 's' should be passed by reference.
[\src\Socket.cpp:142]: (performance) Function parameter 'host' should be passed by reference.
[\src\SoundEffectsHelper.cpp:184] -> [\include\SoundEffectsHelper.h:53]: (information) Technically the member function 'SoundEffectsHelper::registerCreatureClass' can be const.
[\src\Tile.cpp:101]: (information) The scope of the variable tempInt can be reduced
[\src\Trap.cpp:10]: (warning) Member variable 'Trap::type' is not initialised in the constructor.
[\src\Trap.cpp:10]: (warning) Member variable 'Trap::exp' is not initialised in the constructor.
[\src\Trap.cpp:121] -> [\include\Trap.h:35]: (information) Technically the member function 'Trap::getType' can be const.
[\src\Trap.cpp:175] -> [\include\Trap.h:42]: (information) Technically the member function 'Trap::getMeshName' can be const.
[\src\TrapCannon.cpp:9]: (warning) Member variable 'TrapCannon::x' is not initialised in the constructor.
[\src\TrapCannon.cpp:9]: (warning) Member variable 'TrapCannon::y' is not initialised in the constructor.
[\src\Weapon.cpp:7]: (warning) Member variable 'Weapon::damage' is not initialised in the constructor.
[\src\Weapon.cpp:7]: (warning) Member variable 'Weapon::range' is not initialised in the constructor.
[\src\Weapon.cpp:7]: (warning) Member variable 'Weapon::defense' is not initialised in the constructor.
[\src\Weapon.cpp:7]: (warning) Member variable 'Weapon::parentCreature' is not initialised in the constructor.