[Bug middle-end/70424] [4.9/5/6 Regression] Pointer derived from integer gets reduced alignment

bugdal at aerifal dot cx gcc-bugzilla@gcc.gnu.org
Sun Mar 27 21:06:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70424

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #1 from Rich Felker <bugdal at aerifal dot cx> ---
If correct, this can likely break MMIO access in bare-metal applications or
kernel drivers that derive the MMIO addresses via certain types of arithmetic
expressions. Accessing a 32-bit MMIO register as multiple 16-bit or 8-bit
loads/stores is likely to do the wrong thing or not work at all.

I see no reason why GCC should even try to account for the possibility that the
resulting pointer might be misaligned. Unless the pointed-to type has
__attribute__((__aligned__(1))) applied to it, misaligned access is simply UB.


More information about the Gcc-bugs mailing list