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

          Issue ID: 20809
           Summary: return statement might access memory from destructed
                    temporary
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

Hi,

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

--

Reply via email to