array.reverse segfaults

Tomas Lindquist Olsen tomas at famolsen.dk
Wed Oct 22 04:03:57 PDT 2008


Moritz Warning wrote:
> Hi,
> 
> This piece of code segfaults on Debian Linux (with dmd 1.035):
> Can someone tell me why?
> 
> char[] get(char[] str)
> {
>     return new char[](4);
> }
> 
> void main(char[][] args)
> {
>     char[] str =  get("abc");
>    char[] reversed = str.reverse; // <-- access violation
> }

Simpler version:

void main()
{
     char[4] str;
     str.reverse;
}

Crashes in _adReverseChar when trying to memmove (3 - 255) bytes ;)

My best guess is that is just doesn't handle char.init values properly!



More information about the Digitalmars-d mailing list