www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9993] New: const ctor should be preferred than mutable for const obj creation

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: k.hara.pg gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg 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: -------
Apr 25 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9993


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Severity|major                       |blocker


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-04-26 00:11:19 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1939

This is a blocker issue for 2.063 release.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9993



--- Comment #2 from github-bugzilla puremagic.com 2013-04-26 14:46:06 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/1dbcc7c9922480b208f3cf91aa286ea233f2d18b
fix Issue 9993 - const ctor should be preferred than mutable for const obj
creation

https://github.com/D-Programming-Language/dmd/commit/2de30b3cd95c6e59e2acc90d72adb1b1c8a99afc
Merge pull request #1939 from 9rnsr/fix9993

Issue 9993 - const ctor should be preferred than mutable for const obj creation

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 26 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9993


Kenji Hara <k.hara.pg gmail.com> changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 28 2013