Hello,
I'm working on a C++ project requiring an XML parser. I decided
to make it in D so I could easily parse at run-time or
compile-time as I wish.
As our project uses a gcc tool-chain, I naturally use GDC (GCC
9.4.0).
But I have a few problems with D, linking with it, trying to use
better-C and CTFE, etc.
Here's a reduced sample of one of my problems:
parser.d
```
extern(C) int* ct_parse()
{
int* a = new int(42);
return a;
}
```
main.cpp
```
extern "C" const int* ct_parse();
int main(int argc, char ** argv)
{
return *ct_parse();
}
```
Compiling/linking using the following command-lines:
```
gcc -c parser.d -o parser.o
gcc -std=c++17 -c main.cpp -o main.o
gcc main.o parser.o -lstdc++ -lgphobos -lgdruntime -o test
```
It seg-faults...
Here's the output of gdb:
```
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff777858a in gc_qalloc () from
/usr/lib/x86_64-linux-gnu/libgdruntime.so.76
```
Does anyone have any idea what's going on?
(if I just compile a single D file with "int main() { int* a =
new int(42); return *a; }", it works as intended.)