Hacker News new | ask | show | jobs
by infimum 3352 days ago
does anyone know, how hard it would be to have a compiler flag -Wundefined that tells me when i write code with undefined behaviour? this way i can fix these issues myself and don't have to rely on the compiler inferring my intentions.
1 comments

GCC has -fsanitize=undefined. I don't think it detects all kinds of undefined behavior (I haven't tried it myself). You should be able to find more information if you please.

Edit: mannykannot noted somewhere else that clang has the same flag.

These are runtime sanitizers designed to aid testing and fuzzing, not meant for running in production software. It involves instrumentation.