digitalmars.D.bugs - [Issue 6683] New: Skipping declaration with goto resulted in nonsense
- d-bugmail puremagic.com (35/35) Sep 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6683
- d-bugmail puremagic.com (19/19) Sep 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6683
- d-bugmail puremagic.com (10/10) Sep 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6683
- d-bugmail puremagic.com (10/10) Sep 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6683
- d-bugmail puremagic.com (11/11) Oct 26 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6683
- d-bugmail puremagic.com (18/30) Oct 26 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6683
- d-bugmail puremagic.com (14/16) Oct 26 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6683
http://d.puremagic.com/issues/show_bug.cgi?id=6683 Summary: Skipping declaration with goto resulted in nonsense Product: D Version: unspecified Platform: Other OS/Version: Linux Status: NEW Severity: minor Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: destructionator gmail.com --- Comment #0 from Adam D. Ruppe <destructionator gmail.com> 2011-09-16 16:53:35 PDT --- I'm in the middle of a project right now so will be brief and can add more later. Given code like such: ==== auto somethingResult = getSomething(); if(somethingResult.empty) goto dont_have_something; auto something = somethingResult.front; dont_have_something: if(something !is null) { // potential problem here if the result was empty - "something" doesn't refer to what I thought it would! } ======= The goto over the variable declaration probably should have been a compile error, I believe, from the spec. This was kinda a pain to find when it started crashing since the variable actually referred to an entirely different object! I'm using last month's dmd too, so possible it's already been fixed. I just want to post something here before I forget about it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6683 Simen Kjaeraas <simen.kjaras gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simen.kjaras gmail.com --- Comment #1 from Simen Kjaeraas <simen.kjaras gmail.com> 2011-09-16 17:23:19 PDT --- The spec says "It is illegal for a GotoStatement to be used to skip initializations.". ( http://www.d-programming-language.org/statement.html#GotoStatement ) According to the glossary (http://www.d-programming-language.org/glossary.html), "A code construct is illegal if it does not conform to the D language specification. This may be true even if the compiler or runtime fails to detect the error." So the compiler is free to ignore illegal code. A future compiler, potentially not dmd, may indeed flag it as a compile-time error, so any behavior caused by illegal code should be regarded as unpredictable and unreliable. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6683 --- Comment #2 from Adam D. Ruppe <destructionator gmail.com> 2011-09-16 17:38:52 PDT --- Is that saying "bugs in the compiler don't override the spec" or "goto over initializations at your own risk"? If it's the latter, this isn't a bug at all. (I can see how the compiler throwing an error on this could get annoying, so I suppose it could go both ways.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6683 --- Comment #3 from Simen Kjaeraas <simen.kjaras gmail.com> 2011-09-16 17:47:46 PDT --- It's the latter. Not only do you run the risk of your variables being garbage, but your code might not compile on a future compiler. (not that this has ever *not* been a problem with D, mind) The compiler is free to issue an error or not, but the code is definitely wrong. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6683 Kasumi Hanazuki <k.hanazuki gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #4 from Kasumi Hanazuki <k.hanazuki gmail.com> 2011-10-26 12:06:07 PDT --- *** This issue has been marked as a duplicate of issue 602 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 26 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6683 Stewart Gordon <smjg iname.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid CC| |smjg iname.com --- Comment #5 from Stewart Gordon <smjg iname.com> 2011-10-26 14:11:20 PDT --- (In reply to comment #1)The spec says "It is illegal for a GotoStatement to be used to skip initializations.". ( http://www.d-programming-language.org/statement.html#GotoStatement ) According to the glossary (http://www.d-programming-language.org/glossary.html), "A code construct is illegal if it does not conform to the D language specification. This may be true even if the compiler or runtime fails to detect the error."For all I know, that probably means "This may be true even if some compiler, because of a bug in it, fails to detect the error."So the compiler is free to ignore illegal code.Which is the bit of illegal code - the goto statement or the declaration it skips? In my experience, the compiler doesn't ignore either. Moreover, why does the spec bother to forbid anything if compiler writers are free to ignore it all?A future compiler, potentially not dmd, may indeed flag it as a compile-time error, so any behavior caused by illegal code should be regarded as unpredictable and unreliable.So you're claiming all accepts-invalid bugs are really enhancement requests? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 26 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6683 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc --- Comment #6 from bearophile_hugs eml.cc 2011-10-26 15:10:50 PDT --- (In reply to comment #5)Moreover, why does the spec bother to forbid anything if compiler writers are free to ignore it all?Specs are meant to be long-term things. When you write the specs for a language as complex as D you are free to write things that your current working compiler is not yet able to do, or you have not yet implemented. There are several things written in D specs (or TDPL) that DMD is not yet doing. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 26 2011