www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Code compiles and run fine with LDC but segfault with DMD

reply ryuukk_ <ryuukk.dev gmail.com> writes:
The following code compiles and run fine with LDC, but with DMD 
it compiles and then default at runtime


```D
-- app.d
enum Test {A, B, C}

Test test = Test.A;

extern(C) void main()
{
     switch(test)
     {
         default:
         break;
     }
}

```

```
-- object.d
// empty for now
```


`dmd -m64 app.d && ./app.exe` compiles, running it segfault ⛔

`ldc2 -m64 app.d && ./app.exe` compiles, running it works ✅

Now the interesting part


`dmd -g -m64 app.d && ./app.exe` compiles, running it works! ✅

What `-g` does that makes this code compile and work with DMD?
Aug 29 2022
next sibling parent ryuukk_ <ryuukk.dev gmail.com> writes:
I forgot to add: this is on Windows, the problem doesn't exist 
with linux

I reported a bug here: 
https://issues.dlang.org/show_bug.cgi?id=23310
Aug 29 2022
prev sibling next sibling parent zjh <fqbqrr 163.com> writes:
On Monday, 29 August 2022 at 21:46:48 UTC, ryuukk_ wrote:

 What `-g` does that makes this code compile and work with DMD?
I guess it's global sharing. not `tls`.
Aug 29 2022
prev sibling next sibling parent reply wjoe <invalid example.com> writes:
On Monday, 29 August 2022 at 21:46:48 UTC, ryuukk_ wrote:
 What `-g` does that makes this code compile and work with DMD?
This flag adds symbolic debug info. But I'm confident you knew that already.
Aug 30 2022
parent ryuukk_ <ryuukk.dev gmail.com> writes:
On Tuesday, 30 August 2022 at 11:24:21 UTC, wjoe wrote:
 On Monday, 29 August 2022 at 21:46:48 UTC, ryuukk_ wrote:
 What `-g` does that makes this code compile and work with DMD?
This flag adds symbolic debug info. But I'm confident you knew that already.
You didn't understand the question
Aug 30 2022
prev sibling parent ryuukk_ <ryuukk.dev gmail.com> writes:
Problem fixed, i had to copy bunch of other code from druntime

Here is a working object.d: 
https://gist.github.com/ryuukk/53c133f29da5a8326c359a6bb1063207
Aug 30 2022