[Issue 15847] New: It is not an error to call opAssign on an uninitialized object
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Tue Mar 29 07:16:13 PDT 2016
    
    
  
https://issues.dlang.org/show_bug.cgi?id=15847
          Issue ID: 15847
           Summary: It is not an error to call opAssign on an
                    uninitialized object
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: monkeyworks12 at hotmail.com
struct Test
{
    int n;
    int opAssign(int val)
    {
        assert(n == int.init, "n is in an uninitialized state");
        return n = val;
    }
}
void main()
{
    Test t = void;
    //opAssign should not be called here as t is uninitialized
    t = 0; //BOOM
}
--
    
    
More information about the Digitalmars-d-bugs
mailing list