array.reverse segfaults
Bill Baxter
wbaxter at gmail.com
Wed Oct 22 03:28:08 PDT 2008
On Wed, Oct 22, 2008 at 7:16 PM, Moritz Warning <moritzwarning at web.de> 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
> }
Does str.reverse actually return anything?
I think you need to do that as:
str.reverse;
char[] reversed = str;
However, if it's not supposed to return anything, then it's a bug that
it compiles.
If it's supposed to return something, then it's a bug that it crashes.
Does it work doing it as two lines?
--bb
More information about the Digitalmars-d
mailing list