www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=407

           Summary: casting array literals to int causes compiler seg-fault
           Product: D
           Version: 0.169
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: aziz.kerim gmail.com


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!


-- 
Oct 08 2006
next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail 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-----
Oct 12 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=407


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed DMD 0.170


-- 
Oct 18 2006