www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22221] New: [dip1000] pure function can escape parameters


          Issue ID: 22221
           Summary: [dip1000] pure function can escape parameters through
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe, Vision
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

Follow up to issue 20150. The fix for that issue prevented escaping through the
return value, but had the known limitation that even when escaping through
parameters or the return value is not possible, parameters of pure functions
can still be put into an Exception and thrown:

void f_throw(string x)  safe pure
    throw new Exception(x);

void escape_throw_20150()  safe
    immutable(char)[4] str;

If the function isn't `nothrow`, the pure function -> scope parameters
implication shouldn't be done.

Aug 18 2021