Fixing a cppcheck const-ref recommendation breaks soldier

Bug #1024696 reported by Jens Beyer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Invalid
Undecided
Unassigned

Bug Description

Running cppcheck 1.55 reveals a const-ref suggestion in solder.cc.

Fixing this would be by (what I believe is) the default way by modifying the parameter interface of the method.

See attached patch on the fix.

Doing so compiles fine. However, soldiers are suddenly without HP bar and without level information above their heads.

This leaves me puzzled. I would have expected either a compile error, or in case the fix did screw up some pointer errors, a segfault. But it works completely, just without the signs.

Last night, hjd mentioned in IRC that it might as well be that this is not a false positive by cppcheck, but that there is a bug in the soldier code which is revealed by the patch.

So I leave my observation here for someone fit enough to check this.

Setting to confirmed as we tested this last night with hjd :-)

Revision history for this message
Jens Beyer (qcumber-some) wrote :
Revision history for this message
Jens Beyer (qcumber-some) wrote :

With the very competent help of "aggro" from IRC, this mystery has been solved.

The problem is that we need to make sure we don't destroy the inheritance hierarchy by changing the parameter interface so the inherited method is not overwritten anymore but overloaded.

Classes like Bob and Worker need to be changed too.

There is supposedly not a bug regarding this in Soldiers.

As a result of this, aggro suggested a new cppcheck check at http://sourceforge.net/apps/trac/cppcheck/ticket/3978

Closing as invalid. Thanks aggro.

Changed in widelands:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.