www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4517] New: final switch over with base type allows missing values

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4517

           Summary: final switch over with base type allows missing values
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: braddr puremagic.com


--- Comment #0 from Brad Roberts <braddr puremagic.com> 2010-07-27 00:37:46 PDT
---
module finalswitch;

enum foo : ushort
{
    A = 1,
    B = 3
}

void bar(foo f)
{
    final switch(f)
    {
        case foo.A:
            break;
    }
}

This compiles without error:
$ dmd -c finalswitch.d 
$

Dropping the ': ushort' part and it correctly identifies the missing case:
$ dmd -c finalswitch.d 
finalswitch.d(11): Error: enum member B not represented in final switch

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 27 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4517


Denis <verylonglogin.reg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xtzgzorex gmail.com


--- Comment #1 from Denis <verylonglogin.reg gmail.com> 2012-01-24 13:52:28 MSK
---
*** Issue 7320 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: -------
Jan 24 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4517


Denis <verylonglogin.reg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg gmail.com


--- Comment #2 from Denis <verylonglogin.reg gmail.com> 2012-01-24 14:57:22 MSK
---
This bug takes place if the enum base type is [u]byte, [u]short, [w|d]char, or
an enum with one of these types as a base type.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4517


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |yebblies gmail.com
           Platform|Other                       |All
         AssignedTo|nobody puremagic.com        |yebblies gmail.com


--- Comment #3 from yebblies <yebblies gmail.com> 2012-01-31 14:17:31 EST ---
https://github.com/D-Programming-Language/dmd/pull/662

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4517



--- Comment #4 from github-bugzilla puremagic.com 2012-07-16 23:34:17 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/ef6d2e16bebb7c4a0a17eb2c34af2657c9996b38
Issue 4517 - final switch over with base type allows missing values

Integral promotions kills the type of the condition and the case expressions,
so keep track of the original enum type and allow cases to match if they
evaluate to the same integer expression.

Fixes issue4517

https://github.com/D-Programming-Language/dmd/commit/00778d310b6980ac7068398f4dac22aa4860b8d4
Merge pull request #662 from yebblies/issue4517

Issue 4517 - final switch over with base type allows missing values

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 16 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4517


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED


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