enable checks for integer overflow/underflow in debug mode #11657
Replies: 3 comments
-
There are many algorithms (typically those oriented on performance or low-level coding) relying on overflow/underflow (e.g. embedded development, security algorithms, hash/... algorithms, numerical computation algorithms, etc.). So I'm afraid checking overflow/underflow would require dedicated syntax for (dis)allowing such checks. |
Beta Was this translation helpful? Give feedback.
-
If you do: $if !no_overflow_checks ? {
// do slower checks here
} ... then when you compile with Of course it can do the opposite too: $if overflow_checks ? {
// do slower checks
} ... so you can then opt in for slower but potentially safer code by passing I am not sure what approach is best for these. |
Beta Was this translation helpful? Give feedback.
-
My school of thinking was to go down the same route, more or less as for array's index checks. I mean, let's the compiler add or not based on a command line flag (--enforce_overflow_check) if this type of verification will be injected in C code at compile time. However for real life applications the developer will engage --enforce_overflow_check and automatically C code will be added to C source code by the V compiler. |
Beta Was this translation helpful? Give feedback.
-
See #4014
Beta Was this translation helpful? Give feedback.
All reactions