This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug compile/22084] unexpected padding in a struct


https://sourceware.org/bugzilla/show_bug.cgi?id=22084

--- Comment #2 from Dudu <dudu.arbel at ilrd dot co.il> ---
I use gcc. 
the whole file to compile is:

#include "stdio.h"
typedef struct {
        unsigned int x:16;
        unsigned int y:17;
        unsigned short z;
} XXX;


int main() 
{ 
        XXX x = {0};
        x.x = 65536-1;
        x.y = 2*65536-1;
        x.z = 65536-1;

        char *p = (char*)&x;

        printf("1st byte is=%d\n", *p++);
        printf("2nd byte is=%d\n", *p++);
        printf("3rd byte is=%d\n", *p++);

        printf("\nsize of xxx=%ld\n", sizeof(XXX));
}

the output is: -1 (ok), -1 (ok), 0 (!? - wrong padding)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]