Thread overview
[Issue 339] New: Alias of function pointer type cannot be forward referenced
Sep 10, 2006
d-bugmail
May 25, 2009
Gide Nwawudu
May 25, 2009
Don
Jul 07, 2009
Don
[Issue 339] Alias of function pointer type cannot be forward referenced (D1 only)
September 10, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=339

           Summary: Alias of function pointer type cannot be forward
                    referenced
           Product: D
           Version: 0.166
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: smjg@iname.com


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[]
----------


-- 

May 25, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=339


Gide Nwawudu <gide@nwawudu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |gide@nwawudu.com




--- Comment #1 from Gide Nwawudu <gide@nwawudu.com>  2009-05-25 07:29:07 PDT ---
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'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 25, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=339


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |clugdbug@yahoo.com.au




--- Comment #2 from Don <clugdbug@yahoo.com.au>  2009-05-25 13:53:13 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 07, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=339


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |




--- Comment #3 from Don <clugdbug@yahoo.com.au>  2009-07-07 08:22:37 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=339


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrei@metalanguage.com
         Resolution|                            |FIXED


--- Comment #4 from Andrei Alexandrescu <andrei@metalanguage.com> 2010-11-26 11:25:51 PST ---
Could not reproduce in 1.065 and 2.050.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------