News for hackers. Stuff that matters.
Re:Catching integer overflows in C by saagarjha on Wednesday August 22, 2018 @12:42AM (#17816353)
Interesting. Does this compile down to the appropriate assembly instructions for checking for overflow, if available, or does it end up emulating it with a couple dozen instructions? That is, is this low-cost or does it have a measurable performance penalty and should only be used in debug builds?
Re:Catching integer overflows in C by WalterBright on Wednesday August 22, 2018 @06:35AM (#17817691)
It depends on the implementation, which does what it has to do to work with the backend. If the backend supports intrinsics that efficiently check for these things, then they'll be used.

It's really the same issue any language would have with the particular backend it uses.

What's different about the D approach, however, is that the user can select which of several behaviors on overflow, and then select which of several responses to overflow, instead of being stuck with just one or two options. The tests we've run shows it generates the same code as if one had done it by hand.