Bug 642 – error: mixin "static this" into where it cannot be

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2006-12-04T02:23:00Z
Last change time
2014-02-15T13:22:01Z
Keywords
diagnostic, ice-on-invalid-code, patch
Assigned to
bugzilla
Creator
kinaba

Attachments

IDFilenameSummaryContent-TypeSize
305642_check-this.diffVerify isThis() in addPostInvariant() and addPreInvariant().text/plain789
306642_check-dtor.diffValidate that a static destructor has a parent.text/plain670

Comments

Comment #0 by kinaba — 2006-12-04T02:23:38Z
// credit goes to http://f17.aaa.livedoor.jp/~labamba/?BugTrack%2F27 template Foo() { static this(){} } void main() { mixin Foo; } ---------------- Assertion failure: 'ad' on line 877 in file 'func.c' abnormal program termination
Comment #1 by thomas-dloop — 2006-12-07T05:06:45Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-12-04: > http://d.puremagic.com/issues/show_bug.cgi?id=642 > // credit goes to http://f17.aaa.livedoor.jp/~labamba/?BugTrack%2F27 > template Foo() > { > static this(){} > } > > void main() > { > mixin Foo; > } > ---------------- > Assertion failure: 'ad' on line 877 in file 'func.c' > > abnormal program termination Added to DStress as http://dstress.kuehne.cn/nocompile/t/this_14_A.d http://dstress.kuehne.cn/nocompile/t/this_14_B.d http://dstress.kuehne.cn/nocompile/t/this_14_C.d http://dstress.kuehne.cn/nocompile/t/this_14_D.d http://dstress.kuehne.cn/nocompile/t/this_14_E.d http://dstress.kuehne.cn/nocompile/t/this_14_F.d http://dstress.kuehne.cn/nocompile/t/this_14_G.d http://dstress.kuehne.cn/nocompile/t/this_14_H.d http://dstress.kuehne.cn/nocompile/t/this_14_I.d http://dstress.kuehne.cn/nocompile/t/this_14_J.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFd//uLK5blCcjpWoRAvZCAKCTGJoNDgTVbtzDoOqWe2tGCkOpwACeJ8X9 AlznwJrxg03qHRyLa7S6foc= =kFUs -----END PGP SIGNATURE-----
Comment #2 by kamm-removethis — 2008-07-12T02:33:49Z
In LLVMDC we fixed this_14_G/H by making the "constructors/destructors are only for class definitions" error fatal. Otherwise you get a segfault around func.c line 908 trying to access the InvariantDeclaration of the AggregateDeclatation* ad that is zero.
Comment #3 by bugs-d — 2009-03-30T00:28:40Z
Created attachment 305 Verify isThis() in addPostInvariant() and addPreInvariant(). This patch fixes G/H while handling errors normally. All of the other is*Invariant() methods check for ad, but static contructors and desctrutors assume it's there, seemingly. -[Unknown]
Comment #4 by bugs-d — 2009-03-30T00:31:40Z
Created attachment 306 Validate that a static destructor has a parent. This fixes this_14_I. It just adds a clause, similar to the one for static constructors, for static destructors. This throws a very similar error and doesn't crash. -[Unknown]
Comment #5 by clugdbug — 2009-04-20T04:09:49Z
*** Bug 1533 has been marked as a duplicate of this bug. ***
Comment #6 by clugdbug — 2009-04-20T04:15:05Z
Another example of 14G/14H, from bug 1533. [Unknown]'s patch fixes this, but does result in one of the error messages having no line number. --- template T(){ this(int i){} // causes 14G segfault ~this() {} // causes 14H segfault } struct C{ void foo(){ bar(); this.t(7); } mixin T!() t; }
Comment #7 by clugdbug — 2009-05-14T04:54:41Z
Fixed DMD2.030 and 1.045. The segfault bug in 14G and 14H is fixed, as are all of the ICE bugs. 14G has one error without line number ("Error: 'this' is only defined in non-static member functions, not this") but since it comes after errors with line numbers, it's trivial.