Bug 13382 – [e2ir] compare string to int - leads to ICE in e2ir.c 1902

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-08-27T13:38:00Z
Last change time
2015-02-18T03:36:58Z
Keywords
ice, pull
Assigned to
nobody
Creator
gassa

Attachments

IDFilenameSummaryContent-TypeSize
1389example.dexample codetext/plain106

Comments

Comment #0 by gassa — 2014-08-27T13:38:22Z
Reading a string from standard input and trying to compare it with an integer, like this: ----- if ((sn = readln ()) > 0) {} ----- triggers an error: ----- Internal error: e2ir.c 1902 ----- A full example follows. It reproduces for me on DMD 2.065.0-2.066.0 on Win32. With 2.064.2 and earlier, I get a somewhat better "Array operation not implemented" compiler error. Decomposing the problematic line also gives a normal "Incompatible types" error. ----- import std.stdio, std.string; void main () { string sn; if ((sn = readln ()) > 0) { } } ----- The story is that I was first reading an integer, like this: ----- while (readf (" %s", &n) > 0) {...} ----- and later changed reading an integer to reading a string, but forgot to fix the exit condition. Anyway, an internal compiler error does not specify the line of my source file, which is inconvenient.
Comment #1 by gassa — 2014-08-27T13:38:55Z
Created attachment 1389 example code
Comment #2 by hsteoh — 2014-09-11T22:37:26Z
For small code examples, you can just post the entire code in a comment, like so: ----- import std.stdio; void main () { string sn; if ((sn = readln ) > 0) { } } ----- There is no line number in the error message probably because by the time the compiler getse to e2ir.c, it's already emitting code, and by that point the semantic passes may have transformed the code significantly so that line number information may not be readily available. In any case, the error is caused by the `if ((sn = readln) > 0)` line. Now, to hack the dmd makefiles so that I can get it to build with debugging symbols...
Comment #3 by yebblies — 2014-09-12T16:50:26Z
Comment #4 by github-bugzilla — 2014-09-15T09:58:13Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6bef3a57e2e1ba5e1877c3ad7d25672f5bc58ad7 fix Issue 13382 - [e2ir] compare string to int - leads to ICE in e2ir.c 1902 https://github.com/D-Programming-Language/dmd/commit/17e51a018abef9c4842e8fe0d569fc64972a366e Merge pull request #3982 from 9rnsr/fix13382 Issue 13382 - [e2ir] compare string to int - leads to ICE in e2ir.c 1902
Comment #5 by k.hara.pg — 2014-10-08T14:09:15Z
*** Issue 13588 has been marked as a duplicate of this issue. ***
Comment #6 by github-bugzilla — 2015-02-18T03:36:58Z