Bug 407 – casting array literals to int causes compiler seg-fault

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2006-10-08T11:34:00Z
Last change time
2014-02-15T13:19:41Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
aziz.koeksal

Comments

Comment #0 by aziz.koeksal — 2006-10-08T11:34:00Z
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!
Comment #1 by thomas-dloop — 2006-10-12T10:15:45Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] 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-----
Comment #2 by bugzilla — 2006-10-18T13:24:49Z
Fixed DMD 0.170