Bug 3423 – Destructor and postblit don't get copied to the header file when using -H

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-10-20T06:50:00Z
Last change time
2015-06-09T01:26:56Z
Keywords
patch, wrong-code
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2009-10-20T06:50:46Z
This landmine nearly cost us one of our top developers. Hours and hours to track down, less than a minute to patch. Reduced test case: compile with -H. The destructor and postblit don't get copied to the header file. This doesn't generate any compile-time errors, but causes really weird behaviour, including run-time crashes: the functions are present when compiled into a library, but are missing when the library is used. struct Foo { int k; ~this() { k = 1; } this(this) { k = 2; } } PATCH: func.c line 2892 and 2800 void DtorDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { - if (hgs->hdrgen) - return; buf->writestring("~this()"); bodyToCBuffer(buf, hgs); } void PostBlitDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { - if (hgs->hdrgen) - return; - buf->writestring("=this()"); + buf->writestring("this(this)"); bodyToCBuffer(buf, hgs); }
Comment #1 by leandro.lucarella — 2009-10-20T08:45:57Z
I've taken the freedom to change the title because it was very informative really. I hope you don't mind, but using a good title for the bug report help people to find the correct bug and avoids duplicates and bug maintenance overhead. Thanks for the patch BTW :)
Comment #2 by bugzilla — 2009-11-06T11:34:44Z
Fixed dmd 2.036