www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14033] New: runtime error about "auto ptr = cast(T*)buf" , T

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

          Issue ID: 14033
           Summary: runtime error about "auto ptr = cast(T*)buf"  , T is
                    class type
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: mzfhhhh foxmail.com

struct stTest
{
    int a;
    int b;
}
class clsTest
{
    int a;
    int b;
}

void main()
{
    int [100] buf  ;

    auto stPtr = cast(stTest*)buf;
    stPtr.a = 123;//ok

    auto clsPtr = cast(clsTest*)buf;
    clsPtr.a = 123;//run time error
}

--
Jan 23 2015