[Issue 11051] New: Unmatched case in a final switch should throw in both release and non-release mode

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 16 07:14:11 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11051

           Summary: Unmatched case in a final switch should throw in both
                    release and non-release mode
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-09-16 07:14:09 PDT ---
-----
module test;

import std.stdio;

enum E { a }

string get()
{
    auto e = cast(E)123;
    final switch(e)
    {
        case E.a:
            return "foobar";
    }
}

void main()
{
    writeln(get());
}
-----

$ dmd -run test.d
> core.exception.SwitchError at test(10): No appropriate switch clause found

$ dmd -release -run test.d
> x ↑

The release switch ends up making get() return garbage.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list