Hacker News new | ask | show | jobs
by GlitchMr 3511 days ago
The thing is, many compilers just assume that undefined behaviour won't happen, without defining any particular behaviour. And testing for something like pointer alignment on architectures that silently allow pointer misalignment is really, really expensive.

That said, you can use -fsanitize=undefined to verify correctness of a program (as far specification is concerned). Just be prepared for it being a bit slow.

1 comments

It's not possible to determine all possible undefined behavior in a C program. -fsanitize=undefined is best-effort.