#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 , 18 years ago
comment:2 by , 18 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 , 18 years ago
| Owner: | set to |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |
comment:4 by , 18 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 , 8 years ago
| Component: | → Engine: Igor |
|---|

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