[Issue 13902] New: Compiler allows escaping the address of part of a local

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Dec 27 15:36:49 PST 2014


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

          Issue ID: 13902
           Summary: Compiler allows escaping the address of part of a
                    local
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: andrei at erdani.com

Currently the compiler disallows this:

ref int fun() {
  int x;
  return x; // escape the address of a local
}

However, this goes unchecked:

struct S {
    int x;
}

ref int fun() {
  S s;
  return s.x; // escape the address of part of a local
}

Direct member access is easy to check using the same logic, so I'm filing this
as a bug. DIP25 addresses more sophisticated detection cases.

--


More information about the Digitalmars-d-bugs mailing list