www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 339] New: Alias of function pointer type cannot be forward referenced

reply d-bugmail puremagic.com writes:
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[]
----------


-- 
Sep 10 2006
next sibling parent d-bugmail puremagic.com writes:
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





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
prev sibling next sibling parent d-bugmail puremagic.com writes:
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






 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: -------
May 25 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=339


Don <clugdbug yahoo.com.au> changed:

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





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: -------
Jul 07 2009
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Nov 26 2010