www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17897]

https://issues.dlang.org/show_bug.cgi?id=17897

          Issue ID: 17897
           Summary: Зostbit is not called for temporary structures in the
                    function parameters
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: japplegame gmail.com

Test case:

import std.stdio;

struct Foo {
    this(int) {}
    ~this() {}
}

struct Bar {
    this(this) {
        writefln("Bar.this(this): %X", &this);
    }
    this(Foo, Foo) {
        writefln("Bar.this(int): %X", &this);
    }
    ~this() {
        writefln("Bar.~this(): %X", &this);
    }
}

void fun(Bar n) {
    writefln("fun: %X", &n);
}

void main() {
    Foo foo;
    fun(Bar(foo, Foo(0)));
}

Result:

Bar.this(int): XXXXXXXXXXXX
fun: XXXXXXXXXXXX
Bar.~this(): XXXXXXXXXXXX
Bar.~this(): XXXXXXXXXXXX

Expected:

Bar.this(int): XXXXXXXXXXXX
Bar.this(this): XXXXXXXXXXXX
fun: XXXXXXXXXXXX
Bar.~this(): XXXXXXXXXXXX
Bar.~this(): XXXXXXXXXXXX

Discussion: https://forum.dlang.org/post/tvzwzrpwadobzsxcalxy forum.dlang.org

--
Oct 13 2017