[Issue 14033] New: runtime error about "auto ptr = cast(T*)buf" , T is class type

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jan 23 06:17:16 PST 2015


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 at puremagic.com
          Reporter: mzfhhhh at 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
}

--


More information about the Digitalmars-d-bugs mailing list