compiler version: i686-w64-mingw32-g++ (GCC) 4.7.0 20120322 (Fedora MinGW 
4.7.0-2.fc17)

Structures with Bitfields defined as "unsigned int" are not being packed 
properly. They are being packed properly if the bitfields are defined with 
"uint8_t".

Test program:

#include <stdint.h>
#include <stdio.h>

struct v1 {
    unsigned int foo:4;
    unsigned int bar:4;
    uint8_t pad1;
    uint16_t pad2;
} __attribute__ ((__packed__));

struct v2 {
    uint8_t foo:4;
    uint8_t bar:4;
    uint8_t pad1;
    uint16_t pad2;
} __attribute__ ((__packed__));

main(int argc,char **argv)
{
    printf("sizeof(struct v1)=%d\n",sizeof(struct v1));
    printf("sizeof(struct v2)=%d\n",sizeof(struct v2));
    return(0);
}

Output with the native GCC compiler:

$ gcc demo.c
$ ./a.out
sizeof(struct v1)=4
sizeof(struct v2)=4
$

Output with mingw-w64

$ i686-w64-mingw32-g++ --static demo.c
$ wine a.exe
sizeof(struct v1)=8
sizeof(struct v2)=4
$

I've reported a number of bugs on this mailing list. I don't know if that is 
the correct way to report them. My bugs aren't getting fixed, so I'm coding 
around them, but it would be nice for at least someone to acknowledge them...

Simson


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to