Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
GCC 11 da -Wstringop-overflow cuando no se usa ninguna operación de cadena

Aquí está mi código.

 // test.c #include <stdio.h> #define ARRAY_SIZE 4 struct example_t { int field0; int field1; int field2; int field3; int field4; }; struct example_t func(int *in, int array[ARRAY_SIZE]) { struct example_t out; return out; } int main() { int array[ARRAY_SIZE] = { 0, 0, 0, 0 }; int a = 0; struct example_t col = func(&a, array); return 0; }

gcc 11.1.0 dio

 $ gcc test.c -o test test.c: In function 'main': test.c:22:26: warning: 'func' accessing 16 bytes in a region of size 4 [-Wstringop-overflow=] 22 | struct example_t col = func(&a, array); | ^~~~~~~~~~~~~~~ test.c:22:26: note: referencing argument 2 of type 'int *' test.c:14:18: note: in a call to function 'func' 14 | struct example_t func(int *in, int array[ARRAY_SIZE]) { | ^~~~

pero g++ no lo hizo.

No entiendo por qué aparece el mensaje de advertencia, ya que no hay una operación de cadena en mi código y nunca leo la array en func .

Si solo hay 4 o menos campos en struct example_t , GCC no se quejará. ¿Puede alguien explicar por qué está el mensaje aquí y cómo puedo solucionarlo?

Gracias de antemano.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda