Warn about bitfields larger than union

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

I've uploaded a simple C program which shows my query:

http://pastebin.com/BQmG0m3g

Is there a way for GCC to warn when union size is exceeded by a bit-field?


Essentially a union of a type, and a bit-field. The bit-field is larger than the first member of the union. This means that the struct is larger than the uint8_t expected, it compiles as 2 bytes large. Output below.


jon@laptop:~$ gcc -Wall -o union union.c
jon@laptop:~$ ./union
sizeof(test_t): 4
t: 0x0x92f0008
reg0: 0x0x92f0008
reg1: 0x0x92f000a
sizeof(t): 4


Thank you for any feedback

Please keep my email address in any replies.

Best regards, Jon


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux