<div>A)</div><div>Requiring a construct such as <span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">Checked!int is too complicated for the user in general as it requires a lot of code change from the user. It may be useful in certain cases but overflow bugs will crop up in unexpected places.</span></div>
<div><br></div><div>B)</div><div>To help finding such bugs, introduce a special version identifier for checking arithmetic overflow (eg -version=check_arithmetic_overflow) (no new compiler flag syntax, just a built in version identifier).</div>
<div><br></div><div>C)</div><div>It shouldn't be implied by -debug flag as it may slow down debug code significantly, making debug code too slow to be useful. Conflating the "debug" statements and arithmetic overflow is a bad idea; debugging shouldn't be an all or nothing option.</div>
<div><br></div><div>D)</div><div><div>More generally, there's a trade-off between keeping the number of compiler flags low for simplicity and having and having more flags for more expressiveness. I feel dmd is trying too hard to keep the number low. There's a reason why gcc, clang etc have so many flags, which gives user finer control. There should be a good middle ground: the defaults should be simple (optimize vs debug), but when searching for bugs, optimizing or dealing with deprecated constructs, we want flexibility. </div>
</div><div><br></div><div>F)</div><div>Finally, some code may indeed depend on arithmetic overflow, and shouldn't be affected by -version=check_arithmetic_overflow. Maybe we need a way to "unset" a version identifier; here's a possible syntax:</div>
<div><br></div><div>----</div><div>module test;</div><div>version = check_arithmetic_overflow; //existing syntax</div><div>void fun(){}</div><div><br></div><div>version -= check_arithmetic_overflow; //new syntax</div><div>
void fun2(){} //now check_arithmetic_overflow is unset</div><div><div>----</div></div><div><br></div><div>This would be very useful in many ways, eg make some code run fast while the rest is in debug mode (otherwise the debug code would be too slow). </div>
<div><br></div><div><br></div><div><br><div class="gmail_quote">On Thu, May 23, 2013 at 9:13 PM, Marco Leise <span dir="ltr"><<a href="mailto:Marco.Leise@gmx.de" target="_blank">Marco.Leise@gmx.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am Fri, 24 May 2013 01:35:42 +0200<br>
schrieb "Peter Alexander" <<a href="mailto:peter.alexander.au@gmail.com">peter.alexander.au@gmail.com</a>>:<br>
<div class="im"><br>
> What about code that relies on overflow? It's well-defined<br>
> behaviour, so it should be expected that people rely on it (I<br>
> certainly do sometimes)<br>
<br>
</div>See my post about Delphi's approach. It could be disabled in D<br>
using pragma(), UDAs or even scopes.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Marco<br>
<br>
</font></span></blockquote></div><br></div><div><br></div>