digitalmars.D.bugs - This code causes an Internal Error
- Sterling Christensen (30/30) Jul 08 2006 // --- Begin test.d ---
- Thomas Kuehne (16/46) Jul 10 2006 -----BEGIN PGP SIGNED MESSAGE-----
// --- Begin test.d ---
uint octal (char[] s)
{
ubyte shift =3D (s.length - 1) * 3;
uint answer =3D 0;
=
for (int i =3D 0; i < s.length; i++)
{
answer +=3D (s[i] - '0') << shift;
shift -=3D 3;
}
=
return answer;
}
void main ()
{
assert (octal("0777") =3D=3D 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+=3D
6. change the for to a foreach
Jul 08 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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
-----BEGIN PGP SIGNATURE-----
iD8DBQFEsi9ALK5blCcjpWoRAn/qAJ9U0LXRVwi2PJWp5fEA5d+76YhxqACaA8X/
Qw7WEF68kPL6qXLAgDILdhI=
=g0fx
-----END PGP SIGNATURE-----
Jul 10 2006








Thomas Kuehne <thomas-dloop kuehne.cn>