Summary: Copy constructor not called under extremely mysterious
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Andrei Alexandrescu <> 2010-06-20 
20:40:18 PDT ---
I spent the better part of today trying to escape this elusive bug. It's
extremely subtle because it depends on some unrelated code existing or not.
Here it is:

import std.stdio;

struct X(T)
        writeln("I was copied");

void main()
    struct A
        X!int x;
        this(int y)
        A copy()
            auto another = this;
            return another;
    auto a = A(4);
    auto b = a.copy();
    writefln("a: %p, b: %p\n", &a, &b);

At the end of this program the writefln witnesses that we have two objects, but
the stdout is mute so the subobject was not copied.

Changing some code in the example above makes the example work. For example,
replacing A(4) with A() produces a correct program.

Please give this priority (as all ctor/dtor bugs should have). Thanks.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to