digitalmars.D.bugs - [Issue 3820] New: Small hole in switch semantics
- d-bugmail puremagic.com (26/26) Feb 18 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3820
- d-bugmail puremagic.com (12/12) Aug 02 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3820
- d-bugmail puremagic.com (10/10) May 12 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3820
- d-bugmail puremagic.com (16/16) Mar 11 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3820
- d-bugmail puremagic.com (10/10) Mar 12 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3820
- d-bugmail puremagic.com (7/7) Mar 12 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3820
- d-bugmail puremagic.com (10/10) May 19 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3820
- d-bugmail puremagic.com (24/24) May 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3820
http://d.puremagic.com/issues/show_bug.cgi?id=3820 Summary: Small hole in switch semantics Product: D Version: 2.040 Platform: All OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc void main() { switch (1) { int x; case 1: assert(x == int.init); default: } } Here often x != x.init. D isn't C, so it's better to avoid holes in its semantics, if possible. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 18 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3820 Jeffrey Yasskin <jyasskin gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jyasskin gmail.com PDT --- Interestingly, http://www.digitalmars.com/d/2.0/statement.html#GotoStatement says "It is illegal for a GotoStatement to be used to skip initializations." but doesn't say anything of the sort about switch statements. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 02 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3820 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com *** Issue 5989 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 12 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3820 A probably related case: import std.stdio; enum Foo { A } void main() { Foo f = Foo.A; switch (f) { writeln(f); case Foo.A: break; } } With DMD 2.059head it prints nothing. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 11 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3820 dawg dawgfoto.de changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dawg dawgfoto.de *** Issue 7630 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 12 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3820 You can only execute that block with a goto or a loop. The initialization should happen anyhow. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 12 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3820 Maxim Fomin <maxim maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maxim maxim-fomin.ru --- *** Issue 10121 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 19 2013
http://d.puremagic.com/issues/show_bug.cgi?id=3820 IIRC this switch is implemented as below. Unless we expect the block to always run, as in comment 3, it's difficult to fix. int foo(int a) { switch (var) { int res; case 1: res = 1; return res; default: return res; } } int foo(int a) { if (var == 1) goto L1; else goto Ldefault; int res; L1: res = 1; return res; Ldefault: return res; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 20 2013