Bug 20815 – Wrong purity inference for postblit and copy constructor in template struct

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-05-09T12:14:31Z
Last change time
2020-05-09T12:25:21Z
Assigned to
No Owner
Creator
Atila Neves

Comments

Comment #0 by atila.neves — 2020-05-09T12:14:31Z
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()); } --------------------------------