[Issue 2962] ICE(glue.c) or bad codegen passing variable as template value parameter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 17 14:05:50 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=2962


jens.k.mueller at gmx.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |jens.k.mueller at gmx.de
         Resolution|FIXED                       |


--- Comment #42 from jens.k.mueller at gmx.de 2012-08-17 14:05:39 PDT ---
The following code (two modules) shows that this bug is not fixed yet.

module foo;                                                                     

void baz(alias pred)()                                                          
{                                                                               
    pred(0);                                                                    
}

---

module bar;                                                                     

import foo;                                                                     

void bar(int id)                                                                
{                                                                               
    baz!((a)                                                                    
    {                                                                           
        id = 0; // passing a delegate as template argument does not allow       
                // accessing its environment                                    
    })();                                                                       
}

dmd foo.d bar.d
results in:
bar.d(5): Error: function bar.bar compiler error, parameter 'id', bugzilla
2962?
dmd: glue.c:717: virtual void FuncDeclaration::toObjFile(int): Assertion `0'
failed.

Unfortunately I couldn't reduce the test case any further. If the delegate has
no parameter I cannot reproduce the compiler assertion failure. And of course
if id is not accessed from within the delegate the problem goes away. This is
at the core of the problem.
As pointed out in the comments the specified order of files is important. I.e. 
dmd bar.d foo.d compiles just fine.

I used DMD64 D Compiler v2.060.
I'm reopening this bug.

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


More information about the Digitalmars-d-bugs mailing list