934 – Segfault taking mangleof a forward reference in a template.

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 934 - Segfault taking mangleof a forward reference in a template.
Summary: Segfault taking mangleof a forward reference in a template.
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: ice-on-valid-code, patch
Depends on:
Blocks:
Reported: 2007年02月06日 07:17 UTC by Frits van Bommel
Modified: 2014年02月15日 13:13 UTC (History)
1 user (show)

See Also:


Attachments
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 Frits van Bommel 2007年02月06日 07:17:27 UTC
-----
urxae@urxae:~/tmp$ cat test.d
template Templ(T) {
 pragma(msg, Type.mangleof);
 alias T Type;
}
void main() {
 Templ!(int).Type x; // instantiate
}
urxae@urxae:~/tmp$ dmd test.d
dmd: mtype.c:550: virtual Expression* Type::getProperty(Loc, Identifier*): Assertion `deco' failed.
Aborted (core dumped)
-----
Saw this first in DMD v1.005 (not in bugzilla yet), but it fails with v1.00 as well.
Comment 2 Don 2009年04月16日 04:05:15 UTC
Actually it's nothing to do with pragma(msg). It's the mangleof which is the problem. Change it to .stringof and problem disappears.
template Templ(T) {
const char [] XXX = Type.mangleof;
 alias T Type;
}
void main() {
 Templ!(int).Type x; // instantiate
}
====================
Segfaults on DMD2.028.
assert mtype.c(1272) deco
<segfault>
DMD1.042
Assertion failure: 'deco' on line 576 in file 'mtype.c'
abnormal program termination
Comment 3 Don 2009年04月20日 01:55:26 UTC
PATCH: DMD2.028 on mytype.c line 1272, replace assert(deco); with:
	if (!deco) {
		error(loc, ".mangleof forward reference");
		return new StringExp(loc, "ERROR", 5, 'c');
	}
	---
I was surprised to find that in most cases, this error doesn't appear -- seems the compiler absorbs the error and retries in the next semantic pass, and then the code works correctly. In other words, it completely fixes the bug in D2.
From the line number, seems it's a different cause in D1.
Comment 4 Don 2009年05月14日 05:21:07 UTC
Fixed DMD2.030 and 1.045


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