www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11521] New: Switch using same name variable leads to Access Violation

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 puremagic.com
        ReportedBy: temtaime gmail.com


--- Comment #0 from Temtaime <temtaime 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: -------
Nov 15 2013