July 08, 2006 This code causes an Internal Error | ||||
---|---|---|---|---|
| ||||
// --- Begin test.d --- uint octal (char[] s) { ubyte shift = (s.length - 1) * 3; uint answer = 0; for (int i = 0; i < s.length; i++) { answer += (s[i] - '0') << shift; shift -= 3; } return answer; } void main () { assert (octal("0777") == 0777); } // --- End of test.d --- dmd -O test.d Internal error: ../ztc/cgcod.c 1677 dmd v0.162 It compiles if you: 1. don't optimize (no -O) 2. change "return answer" to "return 0" on line 12 3. change the 3 on line 3 to 1, 2, 4, 7, or 8... 5, 6, 9, and 10 still cause the internal error. (I didn't try higher than 10) 4. Change "ubyte shift" to "uint shift" 5. comment out the for or the answer+= 6. change the for to a foreach |
July 10, 2006 Re: This code causes an Internal Error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sterling Christensen Attachments: | Sterling Christensen schrieb am 2006-07-08: > // --- Begin test.d --- > uint octal (char[] s) > { > ubyte shift = (s.length - 1) * 3; > uint answer = 0; > > for (int i = 0; i < s.length; i++) > { > answer += (s[i] - '0') << shift; > shift -= 3; > } > > return answer; > } > > void main () > { > assert (octal("0777") == 0777); > } > // --- End of test.d --- > > dmd -O test.d > Internal error: ../ztc/cgcod.c 1677 > > dmd v0.162 > > It compiles if you: > 1. don't optimize (no -O) > 2. change "return answer" to "return 0" on line 12 > 3. change the 3 on line 3 to 1, 2, 4, 7, or 8... 5, 6, 9, and 10 still > cause the internal error. (I didn't try higher than 10) > 4. Change "ubyte shift" to "uint shift" > 5. comment out the for or the answer+= > 6. change the for to a foreach Added to DStress as http://dstress.kuehne.cn/run/b/bug_cgcod_1667_A.d http://dstress.kuehne.cn/run/b/bug_cgcod_1667_B.d http://dstress.kuehne.cn/run/b/bug_cgcod_1667_C.d http://dstress.kuehne.cn/run/b/bug_cgcod_1667_D.d http://dstress.kuehne.cn/run/b/bug_cgcod_1667_E.d http://dstress.kuehne.cn/run/b/bug_cgcod_1667_F.d Thomas |
Copyright © 1999-2021 by the D Language Foundation