Skip to content

Commit

Permalink
keys.c: disable -Warray-bounds warning from gcc >= 8. seems bogus.
Browse files Browse the repository at this point in the history
In function 'Key_Console',
    inlined from 'Key_Event' at keys.c:1048:3:
keys.c:544:4: warning: 'memmove' offset [-2147483647, -1] is out of the bounds [0, 8192] of object 'key_lines' with type 'char[32][256]' [-Warray-bounds]
    memmove (workline + 1, workline, len);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
keys.c: In function 'Key_Event':
keys.c:25:6: note: 'key_lines' declared here
 char key_lines[32][MAXCMDLINE];
      ^~~~~~~~~
  • Loading branch information
sezero committed Feb 10, 2024
1 parent 13b8be0 commit 3055e70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions engine/hexen2/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,13 @@ static void Key_Console (int key)
workline[MAXCMDLINE - 2] = 0;
workline += key_linepos;
len = strlen(workline) + 1;
#if defined(__GNUC__) && (__GNUC__ > 7)
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
memmove (workline + 1, workline, len);
#if defined(__GNUC__) && (__GNUC__ > 7)
#pragma GCC diagnostic pop
#endif
*workline = key;
}
else
Expand Down
6 changes: 6 additions & 0 deletions engine/hexenworld/client/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,13 @@ static void Key_Console (int key)
workline[MAXCMDLINE - 2] = 0;
workline += key_linepos;
len = strlen(workline) + 1;
#if defined(__GNUC__) && (__GNUC__ > 7)
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
memmove (workline + 1, workline, len);
#if defined(__GNUC__) && (__GNUC__ > 7)
#pragma GCC diagnostic pop
#endif
*workline = key;
}
else
Expand Down

0 comments on commit 3055e70

Please sign in to comment.