[Issue 407] New: casting array literals to int causes compiler seg-fault

Thomas Kuehne thomas-dloop at kuehne.cn
Thu Oct 12 08:10:07 PDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail at puremagic.com schrieb am 2006-10-08:
> http://d.puremagic.com/issues/show_bug.cgi?id=407

> The following code demonstrates in which cases the compiler crashes with a
> segmentation fault:
>
> int i;
> char[1] c = ['0'];
> i = c[0]; // ok
> i = *cast(int*)c; // ok
> //i = *cast(int*)['0']; // compiler seg-fault
> //i = *cast(int*)cast(char[0])[]; // compiler seg-fault
> //i = *cast(int*)cast(char[1])['0']; // compiler seg-fault
> i = *cast(int*)cast(char[1])"0"; // ok
>
> i = *cast(int*)cast(char[3])['0']; // ok
> i = *cast(int*)cast(char[3])['0', '0']; // ok
> //i = *cast(int*)cast(char[3])['0', '0', '0']; // compiler seg-fault
>
> i = *cast(int*)cast(char[4])['0', '0', '0']; // ok
> //i = *cast(int*)cast(char[4])['0', '0', '0', '0']; // compiler seg-fault
>
> i = *cast(int*)cast(char[])['0','0','0']; // ok
>
>
> PS.: This is my first bug report here and I hope it's useful. I really feel a
> lot enthusiastic about D, and wish it to become more widely used. Thank you
> very much, Mr Bright, for putting time and effort into creating a very
> remarkable language!

Added to DStress as
http://dstress.kuehne.cn/run/c/cast_32_A.d
http://dstress.kuehne.cn/run/c/cast_32_B.d
http://dstress.kuehne.cn/run/c/cast_32_C.d
http://dstress.kuehne.cn/run/c/cast_32_D.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD4DBQFFLlTFLK5blCcjpWoRAoX0AJ9mwZ72IEYtKsmufmo5Iutsf2Z3VwCYql6A
XtBSgF2TTmkH5gOkkQjvZw==
=n32d
-----END PGP SIGNATURE-----



More information about the Digitalmars-d-bugs mailing list