Re:The Byte Order Fiasco
by kevin_thibedeau on Saturday May 08, 2021 @11:27AM
(#27087988)
C11 has static_assert: https://gcc.godbolt.org/z/E3bGc95o3
Is also has _Generic() so you can roll up a family of endianness conversion functions and safely change types without blowing up somewhere else with a hardcoded conversion routine.
This is why ubsan is silent and not even injecting a check in to the compiled code.
You can check the alignment constraints with static_assert (something else you can't do in standard C): https://gcc.godbolt.org/z/KTcf9ax6r