This code causes an Internal Error

Thomas Kuehne thomas-dloop at kuehne.cn
Mon Jul 10 03:44:22 PDT 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-----



More information about the Digitalmars-d-bugs mailing list