Bug 4499 – calls to @disabled postblit are emitted

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-07-23T23:55:00Z
Last change time
2011-03-30T14:51:34Z
Keywords
accepts-invalid, patch
Assigned to
nobody
Creator
kamm-removethis

Comments

Comment #0 by kamm-removethis — 2010-07-23T23:55:37Z
The following code triggers the "can't happen" assert. struct S { @disable this(this) { assert(false, "can't happen"); } void foo() {} } auto foo() { S s; return s; } void main() { auto s = foo(); s.foo(); }
Comment #1 by k.hara.pg — 2011-02-26T22:33:22Z
Following patch fixes this bug. src/s2ir.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/src/s2ir.c b/src/s2ir.c index 08d802b..95991b6 100644 --- a/src/s2ir.c +++ b/src/s2ir.c @@ -1252,6 +1252,10 @@ void ReturnStatement::toIR(IRState *irs) { StructDeclaration *sd = ((TypeStruct *)tb)->sym; if (sd->postblit) { FuncDeclaration *fd = sd->postblit; + if (fd->storage_class & STCdisable) + { + fd->toParent()->error(loc, "is not copyable because it is annotated with @disable"); + } elem *ec = el_var(irs->shidden); ec = callfunc(loc, irs, 1, Type::tvoid, ec, tb->pointerTo(), fd, fd->type, NULL, NULL); es = el_bin(OPcomma, ec->Ety, es, ec);
Comment #2 by bugzilla — 2011-03-30T14:51:34Z