D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7506 - Postblit does not called properly with inlining
Summary: Postblit does not called properly with inlining
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: pull, wrong-code
Depends on:
Blocks:
 
Reported: 2012-02-15 06:33 UTC by Kenji Hara
Modified: 2012-05-12 17:25 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2012-02-15 06:33:28 UTC
This is a derived issue from bug 7353.

test.d
----
import std.stdio;
struct S
{
    static uint ci = 0;
    static uint di = 0;
    uint i;

    this(int x) { i = ci++; writeln("new: ", i); }
    this(this)  { i = ci++; writeln("copy ", i); }
    ~this()     { ++di;     writeln("del ", i); }

    S save3()
    {
        return this;
    }
}
void main()
{
    {
        auto s = S(1), t = S(1);
        assert(S.ci == 2);
        t = s.save3();
        assert(S.ci == 3);  // line 23
    }
}

Command line:
----
dmd -inline -run test.d

Output:
----
new: 0
new: 1
del 1
del 0
del 0
core.exception.AssertError@test(23): Assertion failure

Postblit is not called.
Comment 1 SomeDude 2012-04-20 00:43:23 UTC
See also issue 7516
Comment 3 github-bugzilla 2012-05-12 15:07:25 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/af733d53761e8c9e3d53fff3275e0451eb23b20d
fix Issue 7506 - Postblit does not called properly with inlining

https://github.com/D-Programming-Language/dmd/commit/481f5585639de6dbf94e6b80510f767dc5e81b64
Merge pull request #939 from 9rnsr/fix_postblit

Issue 7506 & 7530 more postblit fixes