[Issue 4416] New: Function with ref argument breaks struct method const attribute

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 2 05:29:06 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4416

           Summary: Function with ref argument breaks struct method const
                    attribute
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-07-02 05:29:05 PDT ---
This is a wrong D2 program, because bar() modifies the state of the Foo
instance, despite bar is const, but with v2.047 it compiles and runs with no
errors:


void spam(ref int x) {
    x++;
}
struct Foo {
    int x;
    void bar() const {
        spam(x);
    }
}
void main() {
    Foo b;
    assert(b.x == 0);
    b.bar();
    assert(b.x == 1);
}

-- 
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