digitalmars.D.bugs - [Issue 4158] New: switch segfault
- d-bugmail puremagic.com (28/28) May 04 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4158
- d-bugmail puremagic.com (17/17) May 04 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4158
- d-bugmail puremagic.com (12/21) May 05 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4158
http://d.puremagic.com/issues/show_bug.cgi?id=4158
Summary: switch segfault
Product: D
Version: unspecified
Platform: Other
OS/Version: Linux
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: k-foley onu.edu
DMD 2.045
int main(string[] args)
{
//switch (0) { } // segfaults
switch (0) { case 0: }
//switch (0) { case 1: } // segfaults
switch (0) { case 1: default: }
switch (0) { default: }
return 0;
}
---
Seems to segfault when none of the labels inside the switch are jumped to.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 04 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4158
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |bugzilla digitalmars.com
Resolution| |INVALID
23:44:21 PDT ---
It doesn't actually segfault, it executes a HALT instruction. If there is no
default in a switch, the compiler inserts one of the form:
default: HALT
The idea is that the default should not be implied as fall-through, which it
does in C.
D is behaving as it is designed to.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 04 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4158It doesn't actually segfault, it executes a HALT instruction. If there is no default in a switch, the compiler inserts one of the form: default: HALT The idea is that the default should not be implied as fall-through, which it does in C. D is behaving as it is designed to.http://digitalmars.com/d/2.0/statement.html#SwitchStatement "If none of the case expressions match, and there is not a default statement, a std.switcherr.SwitchError is thrown. The reason for this is to catch the common programming error of adding a new value to an enum, but failing to account for the extra value in switch statements. This behavior is unlike C or C++." Should sync this with the docs. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 05 2010









d-bugmail puremagic.com 