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

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-02-06T07:17:00Z
Last change time
2014-02-15T13:13:23Z
Keywords
ice-on-valid-code, patch
Assigned to
bugzilla
Creator
fvbommel

Comments

Comment #0 by fvbommel — 2007-02-06T07:17:27Z
----- 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 #1 by thomas-dloop — 2007-04-05T11:39:01Z
Comment #2 by clugdbug — 2009-04-16T04:05:15Z
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 by clugdbug — 2009-04-20T01:55:26Z
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 by clugdbug — 2009-05-14T05:21:07Z
Fixed DMD2.030 and 1.045