[Issue 11521] New: Switch using same name variable leads to Access Violation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 15 06:01:33 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11521

           Summary: Switch using same name variable leads to Access
                    Violation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: temtaime at gmail.com


--- Comment #0 from Temtaime <temtaime at gmail.com> 2013-11-15 06:01:31 PST ---
import std.algorithm;

void main() {
    auto arr = [ 1, 3, 4, 2, 3, 8, 2 ];
    int dummy;

    switch(0) {
    case 1:
        auto f = (int a, int b) { return a - dummy < b; };
        sort!f(arr);
        break;
    default:
        auto f = (int a, int b) { return a - dummy < b; };
        sort!f(arr);
    }
}

This code causes AV, renaming second f to f2 runs successful.

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


More information about the Digitalmars-d-bugs mailing list