Called C++ object pointer is null in economy/flag.cc

Bug #1319121 reported by Hans Joachim Desserud
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Invalid
Low
Unassigned

Bug Description

Called C++ object pointer is null in economy /flag.cc.

Found by scan-build. Last seen in r8227.

Tags: economy
Revision history for this message
Hans Joachim Desserud (hjd) wrote :
Changed in widelands:
status: New → Triaged
description: updated
description: updated
description: updated
description: updated
summary: - Called C++ object pointer is null in economy /flag.cc
+ Called C++ object pointer is null in economy/flag.cc
description: updated
Revision history for this message
SirVer (sirver) wrote :

Setting to incomplete for bug sweeping.

Changed in widelands:
status: Triaged → Incomplete
description: updated
Changed in widelands:
status: Incomplete → Triaged
tags: added: economy
description: updated
description: updated
description: updated
Revision history for this message
GunChleoc (gunchleoc) wrote :

I wanted to fix this, but I don't understand why it's complaining:

if (not state) {
    Assuming 'state' is non-null

Why does it assume that state is non-null here? The condition is NOT state.

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

I scratched my head at that one as well. I don't know how the `not` keyword works with non-booleans in C++ though, so I don't know if it simply boils down to an is-null-check.

My second puzzle is that I don't see the link between state and serial. It looks like if state is in such a state (great, overloaded terms :p) that it stays out of the first if, but enters the second, something goes wrong. But I would assume that line 87 would have a similar issue with shorter path to trigger it, but it doesn't get reported for some reason.

description: updated
Revision history for this message
GunChleoc (gunchleoc) wrote :

get_state returns either an iterator or nullptr. nullptr evaluates to false and then will enter the alleged "Assuming 'state' is non-null" branch like it should, so I'd say that this is a false positive.

We have the same code in building.cc, seems like that one doesn't trigger anything.

description: updated
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

I've been unable to reproduce this with scan-build from LLVM 6.0 running on recent revisions. Might have been a false postive all along.

Changed in widelands:
status: Triaged → 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.