On 01/26/2012 08:44 PM, Jacob Carlborg wrote:
On 2012-01-26 10:29, Jacob Carlborg wrote:
I'm trying to port a simple example that uses Clang from C to D but for
some reason the D version results in a segmentation fault.

This is the C code:
http://pastebin.com/4B2JGz9n

This is the D code:
http://pastebin.com/XPBsSVup

The stacktrace from GDB looks like this:

(gdb) r
Starting program: /Users/jacob/development/d/dstep/bin/dstep NSObject.h
Reading symbols for shared libraries .+.. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000004
0x0000000100104139 in clang_formatDiagnostic ()
(gdb) bt
#0 0x0000000100104139 in clang_formatDiagnostic ()
#1 0x0000000100001648 in _Dmain ()
#2 0x000000010001baa5 in D2rt6dmain24mainUiPPaZi7runMainMFZv ()
#3 0x000000010001b671 in D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv ()
#4 0x000000010001baf7 in D2rt6dmain24mainUiPPaZi6runAllMFZv ()
#5 0x000000010001b671 in D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv ()
#6 0x000000010001b5f4 in main ()

I'm using DMD 2.057 on Mac OS X compiling as 64bit.

Any idea what I have done wrong?

I've now found out that I only get this error when compiling as 64bit.
When I compile as 32bit everything works fine.


It is possibly an error in the bindings. What are the C and D declarations of the methods you are using?

Reply via email to