[Issue 6194] [GSoC] Destructor gets called on object before it is copied when calling writeln()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 22 09:56:10 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6194


kennytm at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kennytm at gmail.com


--- Comment #1 from kennytm at gmail.com 2011-06-22 09:51:21 PDT ---
Reduced:

---------------------------------------
struct Test {
    int x;
    ~this() { x = 42; }
}
void formattedWrite(A...)(A args) {
    Test* argsAddresses;
    foreach (a; args) {
        argsAddresses = &a;
        assert(argsAddresses.x != 42, "line 9: unexpected: x == 42");
    }
    assert(argsAddresses.x != 42, "line 11: unexpected: x == 42");
}
int main(string[] argv) {
    auto a = Test(3);
    formattedWrite(a);
    return 0;
}
---------------------------------------
core.exception.AssertError at y.d(11): line 11: unexpected: x == 42
----------------
5   y                                   0x000087e9 onAssertErrorMsg + 73
6   y                                   0x00011be6 _d_assert_msg + 26
7   y                                   0x00001ab6 void
y.formattedWrite!(y.Test).formattedWrite(y.Test) + 138
8   y                                   0x00001944 _Dmain + 24
9   y                                   0x000122e3 extern (C) int
rt.dmain2.main(int, char**).void runMain() + 23
10  y                                   0x00011e8d extern (C) int
rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 29
11  y                                   0x0001232b extern (C) int
rt.dmain2.main(int, char**).void runAll() + 59
12  y                                   0x00011e8d extern (C) int
rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 29
13  y                                   0x00011e27 main + 179
14  y                                   0x00001921 start + 53
----------------
---------------------------------------

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


More information about the Digitalmars-d-bugs mailing list