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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 642 - error: mixin "static this" into where it cannot be
Summary: error: mixin "static this" into where it cannot be
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: Walter Bright
URL:
Keywords: diagnostic, ice-on-invalid-code, patch
: 1533 (view as issue list)
Depends on:
Blocks:
Reported: 2006年12月04日 02:23 UTC by Kazuhiro Inaba
Modified: 2014年02月15日 13:22 UTC (History)
3 users (show)

See Also:


Attachments
Verify isThis() in addPostInvariant() and addPreInvariant(). (789 bytes, patch)
2009年03月30日 00:28 UTC, Unknown W. Brackets
Details | Diff
Validate that a static destructor has a parent. (670 bytes, patch)
2009年03月30日 00:31 UTC, Unknown W. Brackets
Details | Diff
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Kazuhiro Inaba 2006年12月04日 02:23:38 UTC
// 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 Thomas Kühne 2006年12月07日 05:06:45 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
d-bugmail@puremagic.com 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 Christian Kamm 2008年07月12日 02:33:49 UTC
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 Unknown W. Brackets 2009年03月30日 00:28:40 UTC
Created attachment 305 [details] 
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 Unknown W. Brackets 2009年03月30日 00:31:40 UTC
Created attachment 306 [details] 
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 Don 2009年04月20日 04:09:49 UTC
*** Bug 1533 has been marked as a duplicate of this bug. ***
Comment 6 Don 2009年04月20日 04:15:05 UTC
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 Don 2009年05月14日 04:54:41 UTC
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.


AltStyle によって変換されたページ (->オリジナル) /