www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Const array not constant?

Why can CONSTANT arrays be sorted and modified at runtime?
Is this a bug?


int main(char[][] args)
     const char[][] ABCD = [ "DDD", "AAA", "CCC", "BBB"];

     ABCD.sort;        // No error!

     ABCD[3]="333";    // No error too!

     ABCD.reverse;     // Also no error!

     foreach(inout char[] String; ABCD)

     return 0;


Maybe only the struct (that contains the pointer to the data and the 
length of the array) is constant, because adding strings (ABCD ~= "EEE") 
is not allowed. But how can I then make the data constant?

( DMD 0.119 )

Apr 04 2005