digitalmars.D.bugs - [Issue 8521] New: Internal error: e2ir.c 720 when a function uses a template which relies on that function and -release and -inline are used
- d-bugmail puremagic.com (65/65) Aug 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8521
- d-bugmail puremagic.com (15/15) Aug 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8521
- d-bugmail puremagic.com (8/8) Aug 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8521
- d-bugmail puremagic.com (27/30) Aug 21 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8521
- d-bugmail puremagic.com (10/10) Aug 21 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8521
- d-bugmail puremagic.com (12/12) Aug 21 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8521
- d-bugmail puremagic.com (10/10) Aug 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8521
- d-bugmail puremagic.com (13/13) Oct 03 2013 http://d.puremagic.com/issues/show_bug.cgi?id=8521
http://d.puremagic.com/issues/show_bug.cgi?id=8521 Summary: Internal error: e2ir.c 720 when a function uses a template which relies on that function and -release and -inline are used Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: blocker Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: jmdavisProg gmx.com --- Comment #0 from Jonathan M Davis <jmdavisProg gmx.com> 2012-08-08 00:18:00 PDT --- This is currently a blocker for phobos pull request# 743, which make stride, strideBack, and decode work with arbitrary ranges of code units, which is needed for the D lexer for Phobos that I'm working on. This is the reduced code: import std.traits; void main() { auto tmp = "hello"; size_t i = 0; decode(tmp, i); } template isRange(R) { enum bool isRange = is(typeof( { R r = void; auto w = r.front; })); } property dchar front(A)(A a) { size_t i = 0; return decode(a, i); } dchar decode(S)(auto ref S str, ref size_t index) { return decodeImpl(str, index); } private dchar decodeImpl(S)(auto ref S str, ref size_t index) { enum canIndex = isRange!S; assert(0); } It compiles just fine normally, but when you compile with -release and -inline together, it fails to compile, giving this error: decodeImpl(S) Internal error: e2ir.c 720 I think that the problem stems from the fact that isRange depends on decode, which in turn depends on isRange, and something about the inlining process screws it up. Moving the line with isRange from decodeImpl into decode makes the problem going away as does removing front from inside of isRange. And using decode inside of isRange makes it go away as well. So, it seems that the number of levels of indirection has to be at at least a certain level before the failure occurs. The code in pull request# 743 passes its unit tests just fine as long as you don't compile with both -release and -inline, so clearly the code can work, but something about -release and -inline screws it up. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8521 Jonathan M Davis <jmdavisProg gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|blocker |major --- Comment #1 from Jonathan M Davis <jmdavisProg gmx.com> 2012-08-08 12:53:49 PDT --- Okay. I was finally able to find a workaround by moving the test inside of decodeImpl to outside of it, which is leaking its implementation details and forcing a bool with the result of the test to be passed to an overload of decodeImpl which doesn't need the test at all, but it does make it so that the code works, and it doesn't affect the public API at all. So, I'm changing this bug to major rather than blocker. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8521 --- Comment #2 from github-bugzilla puremagic.com 2012-08-19 18:51:50 PDT --- Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/ad177d0cf124d5984e983d30fc481ca2b0f5d7ce Workaround for bug# 8521. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 19 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8521 Rainer Schuetze <r.sagitario gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |r.sagitario gmx.de --- Comment #3 from Rainer Schuetze <r.sagitario gmx.de> 2012-08-21 00:34:00 PDT --- I just hit this bug aswell, but your work-around does not seem to help. With current head from github: module test; import std.utf; dchar foo(string s) { size_t pos; return decode(s, pos); } I get ICE with -inline:m:\s\d\rainers\windows\bin\dmd -c test.dm:\s\d\rainers\windows\bin\dmd -c -inline test.dStatement::doInline() goto __returnLabel; Assertion failure: '0' on line 470 in file 'inline.c' abnormal program terminationm:\s\d\rainers\windows\bin\dmd -c -inline -release test.ddecodeImpl(bool canIndex,S) if (is(S : const(char[])) || isInputRange!(S) && is(Unqual!(ElementEncod ingType!(S)) == char)) Internal error: e2ir.c 720 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 21 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8521 --- Comment #4 from Jonathan M Davis <jmdavisProg gmx.com> 2012-08-21 00:47:26 PDT --- Well, it helps in that the situation is improved enough that dmd's tests passed (which wasn't the case before), but clearly, it doesn't fully get around the problem. Bleh. I guess that I'll have to take another whack at the workaround. It would be _really_ nice if someone could fix this bug though. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 21 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8521 --- Comment #5 from Rainer Schuetze <r.sagitario gmx.de> 2012-08-21 15:05:28 PDT --- It seems that dmd is unable to generate code for the expression return str[index] < codeUnitLimit!S ? str[index++] : decodeImpl!true(str, index); This workaround compiled for me: if(str[index] < codeUnitLimit!S) return str[index++]; return decodeImpl!true(str, index); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 21 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8521 --- Comment #6 from github-bugzilla puremagic.com 2012-08-22 02:27:37 PDT --- Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/038e30c737370d7d0489be2e0e889f0f8f071fad Minor adjustment to better workaround bug# 8521. Apparently, using the ternary operator makes it worse, so I switched it to use if instead. The semantics are identical. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8521 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Version|unspecified |D2 Resolution| |WORKSFORME --- Comment #7 from Walter Bright <bugzilla digitalmars.com> 2013-10-03 18:10:31 PDT --- These examples compile successfully with 2.064 head. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 03 2013