Skip to content

iteration 84 invokes undefined behavior #961

@th-otto

Description

@th-otto

When activating warnings, i get

In file included from /home/sebilla/atari/Vanilla-Conquer/redalert/function.h:108,
                 from /home/sebilla/atari/Vanilla-Conquer/redalert/cell.cpp:79:
In member function ‘int HouseClass::QuantityB(int)’,
    inlined from ‘bool CellClass::Goodie_Check(FootClass*)’ at /home/sebilla/atari/Vanilla-Conquer/redalert/cell.cpp:2367:62:
/home/sebilla/atari/Vanilla-Conquer/redalert/house.h:991:33: warning: iteration 84 invokes undefined behavior [-Waggressive-loop-optimizations]
  991 |         return (BQuantity[index]);
      |                                 ^
/home/sebilla/atari/Vanilla-Conquer/redalert/cell.cpp: In member function ‘bool CellClass::Goodie_Check(FootClass*)’:
/home/sebilla/atari/Vanilla-Conquer/redalert/cell.cpp:2366:47: note: within this loop
 2366 |                                 for (j = 0; j < STRUCT_COUNT; j++) {
      |                                             ~~^~~~~~~~~~~~~~

at

for (j = 0; j < STRUCT_COUNT; j++) {

This is because that array has different sizes depending on FIXIT_ANTS/FIXIT_CSII being defined. Same may also be true for the other arrays.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions