request for integer overflow experimental switch

Timothee Cour thelastmammoth at gmail.com
Wed Jun 5 04:22:06 PDT 2013


can you write a DIP for it (even if it's for experimental only for now)?
It takes a bit more work, but it gathers all the info in 1 place and
incorporate feedback. Right now there are too many scattered threads about
that issue.

As I've suggested before, here's what I would want:

* dmd -check_arithmetic_overflow: not implied by any other flags (including
-debug), because conflating flags is bad and it might slow down debug
builds too much. So this opt-in flag results in no downspeed, unless user
explicitly asks for it (usually when chasing a bug).

* code can query whether the flag is set via
version(check_arithmetic_overflow){...}else{...}

* we need a way to unset the flag in a given scope because pieces of code
may rely on intentional overflow, regardless of whether
check_arithmetic_overflow was provided. This part is a bit tricky, any
ideas? I've proposed this:
http://forum.dlang.org/thread/mailman.835.1370430655.13711.digitalmars-d@puremagic.com#post-mailman.835.1370430655.13711.digitalmars-d:40puremagic.com(scoped
compiler options (cf C++ pragma push/pop). Maybe there are other
ways?




On Tue, Jun 4, 2013 at 11:54 PM, eles <eles at eles.com> wrote:

> Dear all,
>
>  The question of if the integers should overflow or not by default comes
> back now and then and latest was in this thread:
> http://forum.dlang.org/thread/**mailman.739.1370297482.13711.**
> digitalmars-d-learn at puremagic.**com<http://forum.dlang.org/thread/mailman.739.1370297482.13711.digitalmars-d-learn@puremagic.com>(and, before you ask, yes, by me).
>
>  Yes, I am a supporter of this.
>
>  But I am not sure if it is a good idea or no, although for me should be
> just like the -noboundscheck compiler flag, ie the runtime overhead will be
> included only on explicit request.
>
>  But, while I do not dare asking for the feature to be in the language,
> could it be added to the compiler, for a while? Even as undocumented
> feature, for testing by those who would like to.
>
>  Maybe some branch "experimental" or "throw-away" could be created to this
> end.
>
>  After one month of using it people will have their arguments pro or
> contra supported not only by faith, but also by facts.
>
>  Then, after one month, if is a bad feature and an undocumented one,
> silently remove it and, voilà, everything will be just as today is.
>
>  Thank you.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130605/23cd005f/attachment.html>


More information about the Digitalmars-d mailing list