www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20809] New: return statement might access memory from


          Issue ID: 20809
           Summary: return statement might access memory from destructed
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang foerdi.net


See this reduced code: https://run.dlang.io/is/yoyHXC

I would expect that foo() returns 2.
My guess in foo is: The return value of val is saved locally as a ref int and
then the destructor of S is called (the local cache is pointing to 0). Now the
ref value is dereferenced and returned.

The last working version of dmd was 2.089

Maybe this issue is related to https://issues.dlang.org/show_bug.cgi?id=14696

- foerdi

May 08 2020