Bug 339 – Alias of function pointer type cannot be forward referenced (D1 only)

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-09-10T12:05:00Z
Last change time
2014-02-15T13:18:55Z
Keywords
diagnostic, rejects-valid
Assigned to
nobody
Creator
smjg
Depends on
1994
Blocks
340

Comments

Comment #0 by smjg — 2006-09-10T12:05:29Z
The following code fails to compile: ---------- uint[] data; void benchmark(Algorithm alg) { alg(data); } alias void function(uint[]) Algorithm; ---------- D:\My Documents\Programming\D\Tests\bugs\function_forward1.d(4): forward reference to type uint[] ---------- It took me a bit of work to figure what it was on about. How can a built-in type be forward referenced? I then realised that the forward reference was in fact to the Algorithm alias. It turns out that the bug disappears if the parameter is uint rather than uint[]. Although the error line pinpoints the line where the function is called, the error still occurs if a use precedes the alias declaration but the call is placed after it. For example: ---------- uint[] data; void benchmark(Algorithm alg) { test(alg); } alias void function(uint[]) Algorithm; void test(Algorithm alg) { alg(data); } ---------- D:\My Documents\Programming\D\Tests\bugs\function_forward2.d(10): forward reference to type uint[] ----------
Comment #1 by gide — 2009-05-25T07:29:07Z
Code crashes D2. test.d ------ uint data; void benchmark(Algorithm alg) { alg(data); } alias void function(uint) Algorithm; C:> dmd test.d Assertion failure: 't->deco' on line 1125 in file 'mtype.c'
Comment #2 by clugdbug — 2009-05-25T13:53:13Z
(In reply to comment #1) > Code crashes D2. > > test.d > ------ > uint data; > > void benchmark(Algorithm alg) { > alg(data); > } > > alias void function(uint) Algorithm; > > C:> dmd test.d > Assertion failure: 't->deco' on line 1125 in file 'mtype.c' This ICE is fixed by my patch to bug 3010.
Comment #3 by clugdbug — 2009-07-07T08:22:37Z
The internal compiler error is fixed in DMD2.031. In fact it now works completely in D2. Still gives a forward reference error in D1.
Comment #4 by andrei — 2010-11-26T11:25:51Z
Could not reproduce in 1.065 and 2.050.