www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Think, this is an error

reply M <M_member pathlink.com> writes:
char []funk(char [][]s){
int M[256];
char []ARRAY[256];
return "";
}

Tends to chrash some times. It crashed about in 1 time of 8.  It just crashes, I
cant catch any exceptions.
Actually, it was:

char []funk(char [][]s){
int M[256];
char []ARRAY[256];
my code follows........
}
and it crashes.
Then I put 

char []funk(char [][]s){
int M[256];
char []ARRAY[256];
return "";
my code follows........
}
It also crushes.

Thend I put
char []funk(char [][]s){
int M[256];
return ""; 
char []ARRAY[256];
my code follows........
}
It didn't crash

Then I put 

char []ARRAY[256];
char []funk(char [][]s){
int M[256];
return ""; 
my code follows........
}
it worked, and then I put

char []ARRAY[256];
char []funk(char [][]s){
int M[256];
my code follows........
}
And it worked fine.
I think, that if "char []ARRAY[256];" is inside a function, maybe the garbage
collector misanderstands it. Isnt "char []ARRAY[256];"  filled with crap at the
beginning, and if the gbc looks at it, maybe it tries to free random arrays?

M.
Jul 09 2004
parent David Medlock <amedlock nospam.org> writes:
M wrote:
 char []funk(char [][]s){
 int M[256];
 char []ARRAY[256];
 return "";
 }
 

Not sure if it is an error, but this is the only part of syntax that didn't make sense to me. The D declaration should be: char[][256] ARRAY; (if not plz correct me). I don't know Walter allows the old C style to work also? Since D arrays are very un-like C arrays, and C libraries are already linkable, why allow it? I realize it is not syntactically ambigious(ie. allowing it doesn't require any overhead/lookahead) but it just doesn't 'fit' with the rest of the clean syntax. Just my .02. Thanks for the great job as always Walter.
Jul 09 2004