[Issue 20633] New: Struct literals order of evaluation is definition dependent, not call dependent
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Wed Mar  4 02:23:10 UTC 2020
    
    
  
https://issues.dlang.org/show_bug.cgi?id=20633
          Issue ID: 20633
           Summary: Struct literals order of evaluation is definition
                    dependent, not call dependent
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: pro.mathias.lang at gmail.com
```
struct Test
{
    uint a;
    uint b;
    uint c;
}
void main()
{
    auto s = get();
    Test local = { c: 1, a: 2, b: 3 };
    assert(s == local);
}
Test get ()
{
    uint x;
    Test lit = {
        c: ++x,
        a: ++x,
        b: ++x,
    };
    return lit;
}
```
With `dmd -checkaction=context -run bar.d`:
```
core.exception.AssertError at bar.d(12): Test(1, 2, 3) !is Test(2, 3, 1)
----------------
??:? _d_assert_msg [0x1027b354a]
??:? _Dmain [0x1027a5e5d]
```
I don't see it being referenced anywhere and it sort-of defeats the purpose of
different ordering.
--
    
    
More information about the Digitalmars-d-bugs
mailing list