www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - request for integer overflow experimental switch

reply "eles" <eles eles.com> writes:
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 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.
Jun 04 2013
parent Timothee Cour <thelastmammoth gmail.com> writes:
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 pu=
remagic.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 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 puremagic.**com<http://forum.dlang.org/thread/mailman=
.739.1370297482.13711.digitalmars-d-learn puremagic.com>(and, before you as= k, 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 thi=
s
 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=E0, everything will be just as today is.

  Thank you.
Jun 05 2013