Thread overview
[Issue 19965] [DIP1000] Template allows to escape internal pointer
Aug 22, 2019
Mike Franklin
Aug 22, 2019
Mike Franklin
Aug 23, 2019
Mike Franklin
Aug 23, 2019
Mike Franklin
Sep 01, 2019
Dlang Bot
Sep 04, 2019
Mike Franklin
August 22, 2019
https://issues.dlang.org/show_bug.cgi?id=19965

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=20149

--
August 22, 2019
https://issues.dlang.org/show_bug.cgi?id=19965

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150@yahoo.com

--- Comment #1 from Mike Franklin <slavo5150@yahoo.com> ---
If narrowed this issue down to this line in the DMD source code: https://github.com/dlang/dmd/blob/0459e34e20a0631a021550431dfe2411ebe16d3f/src/dmd/escape.d#L1465

When `Foo` is a template, `tf.isscope` is `true`, but when `Foo` is not a template `tf.isscope` is `false`.

`isscope` is set to *true` at https://github.com/dlang/dmd/blob/0459e34e20a0631a021550431dfe2411ebe16d3f/src/dmd/semantic3.d#L1316

It is set to *true` because `funcdecl.vthis.storage_class` is `STC.maybescope`.

That's as far as I got.

--
August 23, 2019
https://issues.dlang.org/show_bug.cgi?id=19965

--- Comment #2 from Mike Franklin <slavo5150@yahoo.com> ---
The problem appears to be with `scope` inference.  In `escape.d` there are many places where `STC.maybescope` is removed after it has been determined that `scope` cannot be inferred.  There is even a function `notMaybeScope` to do this.

I believe all that needs to be done is to call `notMaybeScope(v)` in the right place and for the right conditions so `scope` is no longer inferred for this scenario.

--
August 23, 2019
https://issues.dlang.org/show_bug.cgi?id=19965

--- Comment #3 from Mike Franklin <slavo5150@yahoo.com> ---
Attempted Fix: https://github.com/dlang/dmd/pull/10334

--
September 01, 2019
https://issues.dlang.org/show_bug.cgi?id=19965

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #10334 "Fix Issue 19965 - [DIP1000] Template allows to escape internal pointer" was merged into master:

- e5cc7453b4173d9408ad1efd115f74c720caaa4b by Mike:
  Fix Issue 19965 - [DIP1000] Template allows to escape internal pointer

https://github.com/dlang/dmd/pull/10334

--
September 04, 2019
https://issues.dlang.org/show_bug.cgi?id=19965

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|https://issues.dlang.org/sh |
                   |ow_bug.cgi?id=20149         |

--