This talk will show some of the pitfalls and undefined behavior of C++'s C heritage with respect to built-in types and available operations. It will use the upcoming MISRA-C++ guidelines on that area to motivate and guide a simple integer library that allows easy conformance to what MISRA-C calls "essential type model" and that will be similarly represented in C++. Using that library of "integer" types, you will be able to write code that if it would be using regular integer types would be conforming with MISRA guidelines covering that area. While not "perfect" in the sense of safety it will provide types that do not promote, stick to their signedness and number of bits, wand wrap around. For example, adding an 200_ui8 + 56_ui8 will result in 1_ui8. The implementation will demonstrate the use of enum class types, operator overloading, user-defined literals.
Code is available at
github.com/PeterSommerlad/PSsimplesafeint