[Issue 15306] Delegates with shared context can have unshared aliasing
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Mon Nov  9 04:12:53 PST 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=15306
Jakob Ovrum <jakobovrum at 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 at 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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list