[Issue 9462] New: Delegate breaks immutability
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Wed Feb  6 12:39:39 PST 2013
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=9462
           Summary: Delegate breaks immutability
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: maxim at maxim-fomin.ru
--- Comment #0 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-02-06 12:39:37 PST ---
This should not work, since alternative ways of doing so (including manual
creation of delegate object and initialization of .ptr and .funcptr properties
is rejected) are banned.
import std.stdio;
struct S
{
    int i;
    void bar()
    {
        ++i;
    }
    void foo() immutable
    {
        //bar(); //error   
        (&bar)(); //works, lang hole
    }
}
void main()
{
    immutable S s;
    writeln(s.i);
    s.foo();
    writeln(s.i);
}
dmd is smart enough to avoid delegate allocation, it just issues call directly
to bar()
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list