Opened 15 years ago

Closed 15 years ago

Last modified 5 years ago

#4010 closed defect (fixed)

IGOR: Strange code in drawInventory()

Reported by: eriktorbjorn Owned by: eriktorbjorn
Priority: normal Component: Engine: Igor
Version: Keywords:
Cc: Game:

Description

Current ScummVM CVS:

While building ScummVM with the -O2 compiler option, I ran into the following warning:

engines/igor/igor.cpp: In member function ‘void Igor::IgorEngine::drawInventory(int, int)’: engines/igor/igor.cpp:1308: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true

This is the part of drawInventory() that GCC complains about:

int end = start + 6; if (start <= end) {

Is this deliberate behaviour? It seems risky, at best.

Ticket imported from: #2284199. Ticket imported from: bugs/4010.

Change History (5)

comment:1 by bluegr, 15 years ago

It looks like this whole "if (start <= end)" statement should be removed, as it's always true

comment:2 by eriktorbjorn, 15 years ago

Yes, that's what I would think too. Unless there's overflow involved. When I wrote "It seems risky", I was referring to the overflow part of the warning. The size of an "int" is not guaranteed, so we can't know when it overflows.

But I'd still feel better if I knew what kind of values the engine passes to that function.

comment:3 by eriktorbjorn, 15 years ago

Owner: set to eriktorbjorn
Resolution: fixed
Status: newclosed

comment:4 by eriktorbjorn, 15 years ago

I've removed the test. Since the parameters are used as index into an array with 74 elements, integer overflow seems unlikely, to say the least.

comment:5 by digitall, 5 years ago

Component: Engine: Igor
Note: See TracTickets for help on using tickets.