www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Using Clang with D

reply Jacob Carlborg <doob me.com> writes:
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








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

Any idea what I have done wrong?

-- 
/Jacob Carlborg
Jan 26 2012
parent reply Jacob Carlborg <doob me.com> writes:
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








 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. -- /Jacob Carlborg
Jan 26 2012
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
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








 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?
Jan 26 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-01-26 20:49, Timon Gehr wrote:
 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








 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?
This is the declarations I'm using for this example: http://pastebin.com/fDZ1EftJ This is the complete file with the bindings: https://github.com/jacob-carlborg/dstep/blob/master/clang/c/index.d -- /Jacob Carlborg
Jan 26 2012