When compiled with gcc 4.4.[34] The following code prints fe 01, while it should fe ff. Current svn trunk produces correct results. No flags needed to reproduce.
extern int printf(const char * __restrict, ...); int main() { struct { unsigned bar:1; } foo; foo.bar = 0x1; printf("%02x\n", (unsigned char)(foo.bar * 0xfe)); printf("%02x\n", (unsigned char)(foo.bar * 0xff)); return 0; } gcc -v: Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../gcc-svn/configure --enable-stage1-languages-c --enable-languages=c,c++ Thread model: posix gcc version 4.4.4 20100309 (prerelease) (GCC) -- Summary: Wrong code with bitfields and type casting. Product: gcc Version: 4.4.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: marbacz at gmail dot com GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43323