On Wednesday, 2 February 2022 at 23:21:52 UTC, forkit wrote:
Any reason why compiling this with ldc would cause the exe to crash?

Compiling with DMD (using either declaration of palindrome works just fine though)


// ----

module test;

import std;

void main()
{
    char[] palindrome = cast(char[])"able was I ere I saw elba";

//char[] palindrome = ['a','b','l','e','w','a','s','I','e','r','e','I','s','a','w','e','l','b','a'];

    writeln(palindrome);

// note: The line below causes the exe to crash when compiled with ldc
    // but only if using the first version of palindrome.

    writeln(palindrome.reverse);
}

// ---

This segfaults even on `dmd 2.098.0` for me.
Clearly implementation defined behavior.

Reply via email to