www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18756] New: Escaping address of temporary struct field

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

          Issue ID: 18756
           Summary: Escaping address of temporary struct field
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: nick geany.org

 safe unittest
{
    struct S
    {
        int i;
    }
    auto p = &S().i;
}

This compiles without error with dmd v2.079.0, with or without -dip1000. Adding
a destructor to S does trigger an error.

Also, *without* -dip1000, this  safe code fails to error:

    S s;
    auto p = &s.i;

--
Apr 12 2018