Wednesday, January 30, 2013

Detecting Overflows, Undefined Behaviour and Other Nasties

Graham Lee:

Coming up in a future release of clang is a collection of sanitisers that insert runtime checks for the things described above. If you’re the kind of person who writes assertions like the above in your code, you can swap all that for sanitisers enabled in your debug builds. If you’re not the kind of person who writes those assertions, you probably should enable these sanitisers, then go and find out where else you should be adding assertions.

For example, -fsanitize=integer will print a runtime error if you add two integers and the result would overflow int.

Comments RSS · Twitter

Leave a Comment