tau icon indicating copy to clipboard operation
tau copied to clipboard

question: how can I test for arithmetic overflow

Open matu3ba opened this issue 2 years ago • 3 comments

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.

matu3ba avatar Dec 30 '21 18:12 matu3ba

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 :)

jasmcaus avatar Mar 24 '22 13:03 jasmcaus

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.
  • setup for testing in REPL / test-driven development

matu3ba avatar Apr 11 '22 00:04 matu3ba

I'm going to defer this for a later stage.

jasmcaus avatar Apr 11 '22 14:04 jasmcaus