On 2025-01-18 07:48, Bruno Haible via Gnulib discussion list wrote:
Regarding your trick to do an aligned read on (addr & -alignment) instead of an unaligned read on (addr): I find it good that ASAN catches this, because this trick amounts to exploiting a coincidental property of current hardware. Similarly to accessing (addr + (1 << n)) for 48 < n < 64: some hardware allows this, but it's an ISO C violation nevertheless.
Does the unaligned read trick work even with CheriBSD's memory-safe model? That is an edge case that might need an ifdef or something.
The aligned read trick reminds me a bit of the "adding 0 to a null pointer gives you a null pointer" trick. That also is a violation of ISO C but it works everywhere (even on CheriBSD) and Gnulib assumes it in places.
I hope the null pointer trick will be blessed in a future standard. After all, the point of a standard is not to make innocent programs guilty.