D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20815 - Wrong purity inference for postblit and copy constructor in template struct
Summary: Wrong purity inference for postblit and copy constructor in template struct
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-09 12:14 UTC by Atila Neves
Modified: 2020-05-09 12:25 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Atila Neves 2020-05-09 12:14:31 UTC
The code below shouldn't compile, but does. The postblit function is obviously not pure, but pure code is allowed to call it. Interestingly, marking the postblit as pure explicitly causes it to no longer compile.

--------------------------------
struct Struct(T) {
    this(this) {
        import std.stdio;
        writeln("oops");
    }
}

void fun(Struct!int s) pure;

void gun() pure {
    fun(Struct!int());
}

--------------------------------