Tíquete #48248

gcc-14: connection list size array subscript warning

: 2023-06-15 19:16 Última Atualização: 2023-06-18 14:27

Relator:
Dono:
Tipo:
Estado:
Fechado
Componente:
Marcos:
Prioridade:
5 - Medium
Gravidade:
5 - Medium
Resolução:
Fixed
Arquivo:
1

Details

Building S3_0 with gcc-14 development version:

../../../src/server/sernet.c: In function 'send_ping_times_to_all':
../../../src/server/sernet.c:1471:23: error: array subscript 320 is above array bounds of 'int[320]' [-Werror=array-bounds=]
 1471 |     packet.conn_id_new[i] = pconn->id;
      |     ~~~~~~~~~~~~~~~~~~^~~
In file included from ../../../src/common/networking/packets.h:90,
                 from ../../../src/common/game.h:36,
                 from ../../../src/server/sernet.c:75:
../../../src/common/packets_gen.h:818:7: note: while referencing 'conn_id_new'
  818 |   int conn_id_new[MAX_NUM_CONNECTIONS];
      |       ^~~~~~~~~~~
../../../src/server/sernet.c:1472:23: error: array subscript 320 is above array bounds of 'float[320]' [-Werror=array-bounds=]
 1472 |     packet.ping_time_6[i] = pconn->ping_time;
      |     ~~~~~~~~~~~~~~~~~~^~~
../../../src/common/packets_gen.h:820:9: note: while referencing 'ping_time_6'
  820 |   float ping_time_6[MAX_NUM_CONNECTIONS];
      |         ^~~~~~~~~~~
cc1: all warnings being treated as errors

We do have an assert checking that there should never be more than MAX_NUM_CONNECTIONS rounds in the iteration, but that doesn't count as "protection" against the case the way the compiler would want.

Ticket History (3/4 Histories)

2023-06-15 19:16 Updated by: cazfi
  • New Ticket "gcc-14: connection list size array subscript warning" created
2023-06-16 03:17 Updated by: cazfi
  • Dono Update from (Nenhum) to cazfi
  • Resolução Update from Nenhum to Accepted
Comentário

Seen only in S3_0 (presumably it's the optional capability stuff there causing heuristic to end to different conclusion than in other branches), so patch attached just for that branch.

2023-06-18 14:27 Updated by: cazfi
  • Estado Update from Aberto to Fechado
  • Resolução Update from Accepted to Fixed

Editar

Please login to add comment to this ticket » Login