Bug 14649 – ICE on invalid array operation with string literals

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-06-04T01:42:00Z
Last change time
2015-06-17T21:05:44Z
Keywords
ice, pull
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2015-06-04T01:42:08Z
I found this issue during a check for D2 behavior of issue 1511. With D2 compiler (2.067 or HEAD:a74d774), adding two char arrays makes "invalid array operation". void test1() { char[] a, b; string x, y; auto c = a + b; // Error: invalid array operation a + b (possible missing []) auto z = x + y; // Error: invalid array operation x + y (possible missing []) } And if you apply slice operator, they'll make array operations intentionally. void test2() { char[] a = "abc".dup; char[] b = [char(1), char(2), char(3)]; char[] r = new char[](3); string x = "abc"; string y = [char(1), char(2), char(3)]; r[] = a[] + b[]; assert(r == "bdf"); r[] = x[] + y[]; assert(r == "bdf"); } However, using string literals as the operands will cause ICE. void test3() { char[] r = new char[](3); //r[] = "hel" + "lo."; // Error: invalid array operation x + y (possible missing []) // --> expected r[] = "hel"[] + "lo."[]; // --> Assertion failure (...) on line 1909 in file 'e2ir.c', with HEAD enum s = "abc"; r[] = s[0..3] + "def"[0..3]; // --> Assertion failure (...) on line 1909 in file 'e2ir.c', with HEAD }
Comment #1 by k.hara.pg — 2015-06-04T11:47:30Z
Comment #2 by github-bugzilla — 2015-06-06T04:00:16Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/daae6d75b9bc75a6b4334bac1b24d71d5dca1ae8 fix Issue 14649 - ICE on invalid array operation with string literals https://github.com/D-Programming-Language/dmd/commit/081b819c057bb714691b9eab97a72cf5499d6e6f Merge pull request #4719 from 9rnsr/fix14649 Issue 14649 - ICE on invalid array operation with string literals
Comment #3 by github-bugzilla — 2015-06-17T21:05:44Z