<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Manu:<br>
<div class="im"><br>
> Also, contrary to his claim, I find that wrapping is usually what I<br>
> DO want in this case..<br>
> It's super rare that I write any code that pushes the limits of an int<br>
> (unless we're talking 8-16 bit, see my range+saturation comment before),<br>
> and when I do write code that pushes the range of an int, I can't think of<br>
> a time when I've not wanted to wrap as expected.<br>
<br>
</div>The code you usually write seems rather unusual. I have kind of the opposite situations.<br>
<br>
But first of all, "trapping" ints are needed to avoid bugs in normal code. Some bugs are shown here:<br>
<a href="http://embed.cs.utah.edu/ioc/" target="_blank">http://embed.cs.utah.edu/ioc/</a></blockquote><div><br></div><div>I write C/C++ systems/embedded/games code (not a small industry by any measure), and I'm looking to D as a successor.. I'm NOT interested in D as a replacement for C# (or Java/etc), those languages already exist, are well supported, and I'm happy with them for their purpose. I realise I seem to be one of the odd ones out on this forum currently, hence I like to throw my 2c in from time to time :) .. but I don't believe I'm alone.. the rest of the gamedev community will find D soon enough if the language gets it right...</div>
<div><br></div><div>I did see some examples of the common overflow bugs via links in your OP, but I just have never run into those problems myself.. A couple of them depended on an actual bug in your code. for instance this one:<br>
<pre style="font: normal normal normal 1em/150% 'courier new', courier, monospace; color: rgb(68, 68, 68); font-size: 13px; line-height: 19px; text-align: left; background-color: rgb(255, 255, 255); "><strong>result = result * 10 + cursor - '0';</strong></pre>
<pre style="font: normal normal normal 1em/150% 'courier new', courier, monospace; color: rgb(68, 68, 68); font-size: 13px; line-height: 19px; text-align: left; background-color: rgb(255, 255, 255); "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; line-height: normal; white-space: normal; font-size: small; ">Should have been:</span></pre>
<pre style="font: normal normal normal 1em/150% 'courier new', courier, monospace; text-align: left; background-color: rgb(255, 255, 255); "><pre style="color: rgb(68, 68, 68); line-height: 19px; font-size: 13px; font: normal normal normal 1em/150% 'courier new', courier, monospace; ">
<strong>result * 10 + (cursor - '0')</strong></pre><pre style="color: rgb(68, 68, 68); line-height: 19px; font-size: 13px; font: normal normal normal 1em/150% 'courier new', courier, monospace; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; line-height: normal; white-space: normal; font-size: small; ">This isn't a legitimate runtime error, it's compile time/logic bug. Perhaps a warning should be generated at compile time if the logic can be deduced... (probably impossible)</span></pre>
<pre style="color: rgb(68, 68, 68); line-height: 19px; font-size: 13px; font: normal normal normal 1em/150% 'courier new', courier, monospace; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; line-height: normal; white-space: normal; font-size: small; ">If you're suggesting the reason for trapping overflow's is specifically to CATCH bugs like this, then maybe make is a compiler flag when building a debug binary? (ie. assert on integer overflow).</span></pre>
</pre></div></div>