Bug 5079 – ICE(glue.c, 1103) on undefined symbol during CTFE
Status
RESOLVED
Resolution
DUPLICATE
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-10-18T20:53:00Z
Last change time
2015-06-09T05:15:12Z
Keywords
ice-on-invalid-code
Assigned to
nobody
Creator
sandford
Comments
Comment #0 by sandford — 2010-10-18T20:53:50Z
//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?
Comment #1 by sandford — 2010-10-24T08:47:19Z
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.
Comment #2 by sandford — 2010-10-24T08:54:31Z
P.S. The ICE naturally also affects __traits(compiles, T[0].sizeof ), which make escaping the underlying bugs very difficult.
Comment #3 by sandford — 2010-11-02T00:45:42Z
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++
Comment #4 by clugdbug — 2011-02-11T05:23:49Z
Another duplicate of the most important regression.
*** This issue has been marked as a duplicate of issue 4269 ***