www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4770] New: structs don't correctly copy when alias this is used

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4770

           Summary: structs don't correctly copy when alias this is used
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kieron_brown hotmail.com


--- Comment #0 from Kieron Brown <kieron_brown hotmail.com> 2010-08-30 15:12:05
PDT ---
if alias this is used on a member value (whether simple, or another struct)
copying an instantiated struct no longer results in all struct members
being copied (only the aliased value is copied).

The version is Version D 2.048 (version text copied from changelog)

The problem is best illustrated by a minimal example:

----- self contained d sample starts -----
import std.stdio, std.math;

void main()
{
    auto p = Test(0.5, 0.5);
    assert(0.5 == p.a); // ok
    assert(0.5 == p.b); // ok
    Test q;
    //q = Test(0.5, 0.5);
    //
    // the above line can substitute
    // the one below and the same
    // problem occurs
    q = p;
    if (isNaN(q.b))
        printf("problem replicated\n");
    assert(0.5 == q.a); // ok
    assert(0.5 == q.b); // this fails
}

struct Test
{
    double a;
    double b;
    alias a this;
}
----- end of file -----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4770


David Simcha <dsimcha yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dsimcha yahoo.com
         Resolution|                            |DUPLICATE


--- Comment #1 from David Simcha <dsimcha yahoo.com> 2010-08-30 15:16:14 PDT ---
Dup of Bug 2943.

*** This issue has been marked as a duplicate of issue 2943 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2010