ldc executable crashes with this code

Tejas notrealemail at gmail.com
Thu Feb 3 03:07:04 UTC 2022


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.


More information about the Digitalmars-d-learn mailing list