digitalmars.D.bugs - [Issue 12342] New: Deprecate not reachable code?
- d-bugmail puremagic.com (34/35) Mar 10 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12342
- d-bugmail puremagic.com (11/11) Mar 10 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12342
- d-bugmail puremagic.com (11/12) Mar 10 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12342
- d-bugmail puremagic.com (30/30) Mar 11 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12342
- d-bugmail puremagic.com (16/19) Mar 11 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12342
- d-bugmail puremagic.com (9/13) Mar 11 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12342
- d-bugmail puremagic.com (8/11) Mar 11 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12342
https://d.puremagic.com/issues/show_bug.cgi?id=12342 Summary: Deprecate not reachable code? Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: diagnostic Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc int foo() { int x = 0; goto exit; if (true) x++; x = 20; exit: return x; } void main() {} dmd 2.066alpha gives: test2.d(4,5): Warning: statement is not reachable test2.d(6,5): Warning: statement is not reachable Perhaps it's a good idea to turn such warnings into deprecation messages. This deprecation avoids cases like a famous bug: http://en.wikipedia.org/wiki/Backdoor_%28computing%29In late February 2014, Apple elliptically notified users of their OS of the "goto fail" backdoor that was caused by an error. This error voids the SSL authentication process, and exposes the user to a Man-in-the-middle attack.[12][13][14] The "goto fail" bug is nicely diff-listed by Arthur in the Guardian expose.[14]<http://www.theguardian.com/technology/2014/feb/25/apples-ssl-iphone-vulnerability-how-did-it-happen-and-what-next -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 10 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12342 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies gmail.com The number of false positives puts this firmly in the warning/lint territory IMO. Unreachable code is highly common for me when writing and debugging. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 10 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12342 Jonathan M Davis <jmdavisProg gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg gmx.com PDT ---The number of false positives puts this firmly in the warning/lint territoryIMO. Unreachable code is highly common for me when writing and debugging. Agreed. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 10 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12342 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 05:09:46 PDT --- Personally I find it extremely annoying when I get "unreachable" errors for assert(0);. Sometimes I want to add it just to figure out whether execution has reached some part of my code, e.g.: ----- void function() fp1; void function() fp2; void main() { fp1(); assert(0); // triggers warning fp2(); } ----- Without the assert(0) I can't tell from the stack-trace at what point something went wrong: ------ object.Error: Access Violation ------ With the assert injected, if it is reached I'll get back: core.exception.AssertError test(8): Assertion failure Which at least tells me the code before line 8 works ok. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 11 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12342 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALIDPersonally I find it extremely annoying when I get "unreachable" errors for assert(0);. Sometimes I want to add it just to figure out whether execution has reached some part of my code, e.g.:I think you are using assert(0) for the wrong purposes, assert(0) is a code flow tool, like break and continue, e and it's used to tell the compiler a certain code branch can't be reached. Perhaps you have to throw a Error instead. Given the lack of love you show for this idea, I close down this ER as Invalid. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 11 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12342 06:57:07 PDT ---I think you are using assert(0) for the wrong purposes, assert(0) is a code flow tool, like break and continue, e and it's used to tell the compiler a certain code branch can't be reached. Perhaps you have to throw a Error instead.It's just a temporary use to find problems. Anywho the real problem is the complete lack of stacktraces when a null function pointer is called. I'm not sure whether this is filed. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 11 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12342the real problem is the complete lack of stacktraces when a null function pointer is called. I'm not sure whether this is filed.Null pointers in D are not protected by an assert. This is a design decision of Walter that lot of people (me included) doesn't like. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 11 2014