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:
--089e0115f39667366904de66680c
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

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=

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 =

 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=

 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.

--089e0115f39667366904de66680c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable can you write a DIP for it (even if it&#39;s for experimental only for now)= ?<div>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.</div> <div><br></div><div>As I&#39;ve suggested before, here&#39;s what I would w= ant:</div><div><br></div><div>* 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 n= o downspeed, unless user explicitly asks for it (usually when chasing a bug= ).</div> <div><br></div><div>* code can query whether the flag is set via version(ch= eck_arithmetic_overflow){...}else{...}</div><div><br></div><div>* 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 p= rovided. This part is a bit tricky, any ideas? I&#39;ve proposed this:=A0<a= href=3D"http://forum.dlang.org/thread/mailman.835.1370430655.13711.digital= mars-d puremagic.com#post-mailman.835.1370430655.13711.digitalmars-d:40pure= magic.com">http://forum.dlang.org/thread/mailman.835.1370430655.13711.digit= almars-d puremagic.com#post-mailman.835.1370430655.13711.digitalmars-d:40pu= remagic.com</a> (scoped compiler options (cf C++ pragma push/pop). Maybe th= ere are other ways?</div> <div><br></div><div><br></div><div><br></div><div><div><br><div class=3D"gm= ail_quote">On Tue, Jun 4, 2013 at 11:54 PM, eles <span dir=3D"ltr">&lt;<a h= ref=3D"mailto:eles eles.com" target=3D"_blank">eles eles.com</a>&gt;</span>= wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex">Dear all,<br> <br> =A0The question of if the integers should overflow or not by default comes = back now and then and latest was in this thread: <a href=3D"http://forum.dl= ang.org/thread/mailman.739.1370297482.13711.digitalmars-d-learn puremagic.c= om" target=3D"_blank">http://forum.dlang.org/thread/<u></u>mailman.739.1370= 297482.13711.<u></u>digitalmars-d-learn puremagic.<u></u>com</a> (and, befo= re you ask, yes, by me).<br> <br> =A0Yes, I am a supporter of this.<br> <br> =A0But 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.<br> <br> =A0But, while I do not dare asking for the feature to be in the language, c= ould it be added to the compiler, for a while? Even as undocumented feature= , for testing by those who would like to.<br> <br> =A0Maybe some branch &quot;experimental&quot; or &quot;throw-away&quot; cou= ld be created to this end.<br> <br> =A0After one month of using it people will have their arguments pro or cont= ra supported not only by faith, but also by facts.<br> <br> =A0Then, after one month, if is a bad feature and an undocumented one, sile= ntly remove it and, voil=E0, everything will be just as today is.<br> <br> =A0Thank you.<br> </blockquote></div><br></div></div> --089e0115f39667366904de66680c--
Jun 05 2013