[Issue 5798] New: Swap and comma operator

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 30 13:23:26 PDT 2011


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

           Summary: Swap and comma operator
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: timon.gehr at gmx.ch


--- Comment #0 from timon.gehr at gmx.ch 2011-03-30 13:19:58 PDT ---
Hello,

The following code fails the assertion:

import std.algorithm;
import std.stdio;

int main(){
    int a=1,b=0,c;
    swap(a,b),c=b;                                           
    assert(a==0);
    return 0;
}



(This one passes:

import std.stdio;

int main(){
    int a=1,b=0,c;
    tmp=b,b=a,a=tmp,c=b;                                      
    assert(a==0);
    return 0;
}

As well as this one: 

import std.algorithm;
import std.stdio;

int main(){
    int a=1,b=0,c;
    swap(a,b);c=b;                                           
    assert(a==0);
    return 0;
} )

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