www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10978] New: Better support of emplace for structs with immutable members


           Summary: Better support of emplace for structs with immutable
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: monarchdodra gmail.com
        ReportedBy: monarchdodra gmail.com

--- Comment #0 from monarchdodra gmail.com 2013-09-06 01:51:44 PDT ---
emplace was recetly improved to (better) support structs that have immutable

Implementation-wise, it was actually "lucky" it worked (code wasn't written to
explicitly support it), and generated runtime that does it is sub-optimal
(calls to memcpy when an assignment would be enough, calls to tid.postblit that
aren't actually necessary.). Details.

More importantly though, support is "flakey" in the sense that "postblit"
initialization will work (S to S), but aggregate initialization will fail.

import std.conv;

struct S
    immutable int i;

void main()
    S s = void;
    emplace(&s, S(1)); //Fails 2.063.2; Passes 2.064ALPHA
    emplace(&s, 1); //Fails on both 2.063.2 and 2.064ALPHA

So, in 2.064ALPHA, while "emplace(&s, S(1));" will work, "emplace(&s, 1);" will
not. This is inconsistent, and emplace should be fixed to support it.

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