[Issue 3483] New: Eliminate read-modify-write operations for enums

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 6 22:16:03 PST 2009


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

           Summary: Eliminate read-modify-write operations for enums
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrei at metalanguage.com


--- Comment #0 from Andrei Alexandrescu <andrei at metalanguage.com> 2009-11-06 22:16:03 PST ---
Consider:

enum E { a = 5, b = 10, c = 15; }

Arithmetic involving an E are accepted, e.g. E.a + 42, and that's fine because
they yield type int which is not convertible back to E. The problem is that
read-modify-write expressions are allowed too:

E.a x;
x += 42;

Such operations are nonsensical because they take an enum value easily in
places that have nothing to do with the actual defined values.

All operations <op>= and also ++ and -- should be disabled for enums.

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