Thread overview
[Issue 22782] [dip1000] string escaped by throwing constructor
Feb 16, 2022
Ate Eskola
[Issue 22782] [dip1000] address of ref can be assigned to non-scope parameter
Feb 16, 2022
Dennis
Feb 16, 2022
Dennis
Feb 16, 2022
Dlang Bot
Feb 16, 2022
Dennis
Feb 18, 2022
Dlang Bot
February 16, 2022
https://issues.dlang.org/show_bug.cgi?id=22782

--- Comment #1 from Ate Eskola <Ajieskola@gmail.com> ---
Also triggered with an assertion:
------
struct DontDoThis
{ immutable char[12] content;
  @safe this(char ch)
  { content[] = ch;
    assert(0, content[]);
  }
}

void main() @safe
{ DontDoThis('a');
}
------

--
February 16, 2022
https://issues.dlang.org/show_bug.cgi?id=22782

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe, Vision
                 CC|                            |dkorpel@live.nl
           Hardware|x86_64                      |All
            Summary|[dip1000] string escaped by |[dip1000] address of ref
                   |throwing constructor        |can be assigned to
                   |                            |non-scope parameter
                 OS|Linux                       |All

--- Comment #2 from Dennis <dkorpel@live.nl> ---
This isn't about constructors or exceptions, it reduces to:

```
@safe:
void fun(ref int x)
{
    int* scopePtr = &x; // correctly inferred scope
    escape(scopePtr); // correctly rejected

    escape(&x); // accepts invalid
}

int* gPtr;
void escape(int* ptr) {
    gPtr = ptr;
}
```

My fix for issue 12812 (https://github.com/dlang/dmd/pull/12812) was not tested thoroughly enough, I will look into it.

--
February 16, 2022
https://issues.dlang.org/show_bug.cgi?id=22782

--- Comment #3 from Dennis <dkorpel@live.nl> ---
(In reply to Dennis from comment #2)
> My fix for issue 12812

Correction: issue 20245

--
February 16, 2022
https://issues.dlang.org/show_bug.cgi?id=22782

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@dkorpel created dlang/dmd pull request #13672 "Fix Issue 22782 - address of ref can be assigned to non-scope parameter" fixing this issue:

- Fix Issue 22782 - address of ref can be assigned to non-scope parameter

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

--
February 16, 2022
https://issues.dlang.org/show_bug.cgi?id=22782

--- Comment #5 from Dennis <dkorpel@live.nl> ---
*** Issue 22783 has been marked as a duplicate of this issue. ***

--
February 18, 2022
https://issues.dlang.org/show_bug.cgi?id=22782

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

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

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #13672 "Fix Issue 22782 - address of ref can be assigned to non-scope parameter" was merged into master:

- b533cf65ff9467a147fc65390ae2e0363e2ce358 by dkorpel:
  Fix Issue 22782 - address of ref can be assigned to non-scope parameter

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

--