[Issue 4158] switch segfault

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=4158

Andrei Alexandrescu and...@erdani.com changed:

   What|Removed |Added

Version|unspecified |D2

--


[Issue 4158] switch segfault

2010-05-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4158


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||INVALID


--- Comment #1 from Walter Bright bugzi...@digitalmars.com 2010-05-04 
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: ---


[Issue 4158] switch segfault

2010-05-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4158



--- Comment #2 from Kyle Foley k-fo...@onu.edu 2010-05-05 14:21:13 PDT ---
(In reply to comment #1)
 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.

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: ---