Thread overview
[Issue 15306] Delegates with shared context can have unshared aliasing
Nov 09, 2015
Jakob Ovrum
Nov 10, 2015
Sobirari Muhomori
Jul 29, 2016
Sobirari Muhomori
Jul 30, 2016
ZombineDev
Aug 27, 2016
Walter Bright
Oct 03, 2016
anonymous4
November 09, 2015
https://issues.dlang.org/show_bug.cgi?id=15306

Jakob Ovrum <jakobovrum@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Delegates with shared       |Delegates with shared
                   |context                     |context can have unshared
                   |                            |aliasing

--- Comment #1 from Jakob Ovrum <jakobovrum@gmail.com> ---
(In reply to Jakob Ovrum from comment #0)
> void main()
> {
> 	int i = 42;
> 
> 	// Correctly prevented for immutable context
> 	// auto dg = delegate void() immutable { auto inner = i; };
> 
> 	// Incorrectly allowed; context has unshared aliasing
> 	int* p = &i;
> 	auto dg = delegate int() shared { return *p; };
> 	assert(dg() == i);
> }
> 
> ---
> 
> Also, there doesn't appear to be any inference of the context type qualifier, neither for function literals nor nested functions. Taking the address of a member function of an immutable/shared object doesn't seem to give the context type qualifier either.

--
November 10, 2015
https://issues.dlang.org/show_bug.cgi?id=15306

--- Comment #2 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
Looks like quite non-trivial feature and delegates don't provide much type safety anyway.

--
July 29, 2016
https://issues.dlang.org/show_bug.cgi?id=15306

Sobirari Muhomori <dfj1esp02@sneakemail.com> changed:

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

--
July 30, 2016
https://issues.dlang.org/show_bug.cgi?id=15306

ZombineDev <petar.p.kirov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe
                 CC|                            |petar.p.kirov@gmail.com

--
August 27, 2016
https://issues.dlang.org/show_bug.cgi?id=15306

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |bugzilla@digitalmars.com

--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> ---
https://github.com/dlang/dmd/pull/6093

--
August 27, 2016
https://issues.dlang.org/show_bug.cgi?id=15306

--- Comment #4 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/96136d6e4b1330650ca1fbf5afa57c2758ee18d3 fix Issue 15306 - Delegates with shared context can have unshared aliasing

https://github.com/dlang/dmd/commit/fa9cea7a43fe8ccdd483fac11c3c1a194aab1336 Merge pull request #6093 from WalterBright/fix15306

fix Issue 15306 - Delegates with shared context can have unshared aliā€¦

--
August 27, 2016
https://issues.dlang.org/show_bug.cgi?id=15306

github-bugzilla@puremagic.com changed:

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

--
October 01, 2016
https://issues.dlang.org/show_bug.cgi?id=15306

--- Comment #5 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/96136d6e4b1330650ca1fbf5afa57c2758ee18d3 fix Issue 15306 - Delegates with shared context can have unshared aliasing

https://github.com/dlang/dmd/commit/fa9cea7a43fe8ccdd483fac11c3c1a194aab1336 Merge pull request #6093 from WalterBright/fix15306

--
October 03, 2016
https://issues.dlang.org/show_bug.cgi?id=15306

--- Comment #6 from anonymous4 <dfj1esp02@sneakemail.com> ---
How about const qualifier?

void f()
{
    int i = 42;
    auto dg = delegate void() const { i=0; }; //ok?
}

--