www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13297] New: [CTFE] Modifications of user type pointer member

https://issues.dlang.org/show_bug.cgi?id=13297

          Issue ID: 13297
           Summary: [CTFE] Modifications of user type pointer member
                    passed by ref in function disappear
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: CTFE, wrong-code
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: verylonglogin.reg gmail.com

This code should compile fine:
---
struct S
{
    int* p;
}

void f(ref int* p)
{
    p = cast(int*) 1;
    assert(p); // passes
}

void main()
{
    static assert(
    {
        S s;
        f(s.p);
        return s.p == null; // false
    } ());
}
---

--
Aug 15 2014