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

148
Vistas
Is the compiler allowed to modify padding bytes

Suppose I have a snippet of code like this (and assume that the padding is inserted as I say in the comment):

#include "stdint.h"

struct A
{
    uint8_t x;
    // 3 bytes of padding
    uint32_t y;
};


void foo(struct A* a)
{
    a->x = 0;
}

Is the compiler allowed to clear the padding bytes or do anything to the padding bytes in the function foo?

https://en.cppreference.com/w/c/language/object is silent on this issue, which leads me to believe that yes the compiler is allowed to do this....

The reason that I want to know whether or not the compiler is allowed to do this is I want to memcmp two structs, and I want to know what I am allowed to assume....

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Yes. C 2018 6.2.6.1 6 says:

When a value is stored in an object of structure or union type, including in a member object, the bytes of the object representation that correspond to any padding bytes take unspecified values…

over 4 years ago · Santiago Trujillo Denunciar
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