www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5079] New: [ICE on invalid code] '0' on line 1103 in file 'glue.c' on undefined symbol during CTFE

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5079

           Summary: [ICE on invalid code] '0' on line 1103 in file
                    'glue.c' on undefined symbol during CTFE
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: sandford jhu.edu


--- Comment #0 from Rob Jacques <sandford jhu.edu> 2010-10-18 20:53:50 PDT ---
//import std.conv; // the forgotten import

string nthLabel(int n) {
    return "__Global_"~ to!string(n); 
}
template getGlobal(string file = __FILE__, int line = __LINE__, int N = 0) {
    static if( !__traits(compiles, mixin(nthLabel(N)) ) )
        int getGlobal = N;
    else
        int getGlobal = getGlobal!(file,line, N+1 );
}
enum Foo    = getGlobal!(__FILE__, __LINE__) ;

Assertion failure: '0' on line 1103 in file 'glue.c' when std.conv not imported

Comment out enum Foo and the correct error message appears:

template instance template 'to' is not defined, did you mean n?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 18 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5079


Rob Jacques <sandford jhu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
           Severity|normal                      |blocker


--- Comment #1 from Rob Jacques <sandford jhu.edu> 2010-10-24 08:47:19 PDT ---
This ICE/assertion error is also tripping up std.variant, specifically using
DMD 2.049 the following:

import std.variant;
void main(string[] args) {
    Algebraic!(This[string]) ice;
}

Results in an [ICE] Assertion failure: '0' on line 1103 in file 'glue.c'

Tracing this down, this is the offending piece of code.

template maxSize(T...) {
    enum size_t maxSize = T[0].sizeof;
}
struct This;
enum foobar = maxSize!(This[string]);

In this case, the correct error is
Error: struct This is forward referenced

This has been blocking Phobos development, both in std.variant and with regard
to improving std.json by using Algebraic, so I've upgraded the importance.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 24 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5079



--- Comment #2 from Rob Jacques <sandford jhu.edu> 2010-10-24 08:54:31 PDT ---
P.S. The ICE naturally also affects __traits(compiles, T[0].sizeof ), which
make escaping the underlying bugs very difficult.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 24 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5079



--- Comment #3 from Rob Jacques <sandford jhu.edu> 2010-11-02 00:45:42 PDT ---
Having just debugged/patched/filed Issue 5155, I've found that A) that this
test case is a different error and B) they both result from trying to calling
toIR on a statement containing an expression with an __error type (current ty
== 37). In the case of 5155, while debugging I found that detecting the
erroneous ReturnStatement inside the CompoundStatement and eliding it produced
the correct error message (though this might have been as much luck, as
anything else). Looking at the source code, although if(exp) gets tested a fair
amount, if(exp->type->ty == terror) never does, so I'm assuming that the code
that checks for __error inside expressions lives elsewhere. 

Also, here is the stack track from DMD 2.050 for the bug in this report
(Generated using cv2pdb and MSVC). 

    dmd.exe!halt()  Line 231 + 0x2 bytes    C++
     dmd.exe!Type::totym()()  Line 1103    C++
     dmd.exe!IntegerExp::toElem(IRState*)(IRState * irs)  Line 1224 + 0x14
bytes    C++
     dmd.exe!eval_Darray(IRState * irs, Expression * e)  Line 521 + 0xe bytes  
 C++
     dmd.exe!CatExp::toElem(IRState*)(IRState * irs)  Line 2111 + 0xe bytes   
C++
     dmd.exe!ReturnStatement::toIR(IRState*)(IRState * irs)  Line 1292 + 0x11
bytes    C++
     dmd.exe!CompoundStatement::toIR(IRState*)(IRState * irs)  Line 1344    C++
     dmd.exe!FuncDeclaration::toObjFile(int )(int multiobj)  Line 914    C++
     dmd.exe!Module::genobjfile(int )(int multiobj)  Line 280    C++
     dmd.exe!main(int argc, char * * argv)  Line 1295    C++
     dmd.exe!_mainCRTStartup()  + 0xa9 bytes    C++

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 02 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5079


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #4 from Don <clugdbug yahoo.com.au> 2011-02-11 05:23:49 PST ---
Another duplicate of the most important regression.

*** This issue has been marked as a duplicate of issue 4269 ***

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