https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77599
Jeffrey A. Law <law at redhat dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |law at redhat dot com Resolution|--- |INVALID --- Comment #2 from Jeffrey A. Law <law at redhat dot com> --- The problem here is you're using -mshort on *-linux-gnu which IMHO is invalid. Linux defines int32_t as a "int". And -mshort changes the width of an int to 16 bits, at which point anything prototyped using int32_t has just changed its ABI in a meaningful way (similarly for uint32_t, but unsigned). You can see this in the .optimized dump file: x (long unsigned int y) { unsigned int _1; unsigned int _2; long unsigned int _4; ;; basic block 2, loop depth 0, count 0, freq 10000, maybe hot ;; prev block 0, next block 1, flags: (NEW, REACHABLE, VISITED) ;; pred: ENTRY [100.0%] (FALLTHRU,EXECUTABLE) _1 = (unsigned int) y_3(D); _2 = __builtin_bswap32 (_1); _4 = (long unsigned int) _2; return _4; } Note the type of the _1 and _2. They are both unsigned ints, so 16 bits. If you try this test on a bare metal target such as m68k-elf or without the -mshort, you'll get the expected and desired result.