[Issue 9993] New: const ctor should be preferred than mutable for const obj creation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 25 23:56:30 PDT 2013


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

           Summary: const ctor should be preferred than mutable for const
                    obj creation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2013-04-25 23:56:29 PDT ---
This code should work, but currently fails at the last assertion in runtime.

class B
{
    int x;
    this() const { x = 42; }
    this()       { x = 13; }
}
void main()
{
    const B mb = new B;
    assert(mb.x == 13);
    const B cb = new const B;
    assert(cb.x == 42); // fails!
}

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