tau
tau copied to clipboard
question: how can I test for arithmetic overflow
Is there even a simple way to macro overload arithmetic expressions to auto-insert overflow checks ie via SEI Standard https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152052 ?
Alternatively documentation how to emit the instructions for testing with clang/gcc would be great.
Not quite sure that Tau's at that level yet. It's really meant to be a basic-yet-powerful testing library, but some features might not be available. Have a look at it and see if it's something you can contribute to :)
The best we can do is to give some advice on the compiler flags, as such macro system would end up being a template language. Alternatively, we can look for a c++ template implementation, but this would mean potential maintenance annoyance.
-
-ftrapv
and for the much saner 2s complement-fwrapv
to trap on overflow - sanitizing undefined behavior https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
other stuff:
- valgrind
-
-Weverything
+ orientation how to select a sane subset of warnings. - ~~something like
-Wcast-align
being utterly useless (breaks on pointer cast *u8->*u32),-Wformat
being annoying on address printing in wiki page.~~ Casting pointers from lower to higher alignment is UB and more optimization tailored compilers will introduce weird behavior (clang, gcc) unless given a flag. - setup for testing in REPL / test-driven development
I'm going to defer this for a later stage.