August 22, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4710

           Summary: writeln crashes when called from C code.
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Mac OS X
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: kennytm@gmail.com


--- Comment #0 from kennytm@gmail.com 2010-08-22 01:44:15 PDT ---
Given the following content:

  // x.d
  import std.stdio;
  extern (C) void foo() {
      writeln("1");
  }

  // y.c
  void foo(void);
  int main () {
      foo();
      return 0;
  }

And compile and run with

  gcc -c -m32 y.c -o y.o
  dmd x.d y.o -ofx
  ./x

Result in a Bus Error on Mac OS X. (I am using dmd r620, druntime r370 and
Phobos r1900.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 13, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4710


Denis Shelomovskij <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |verylonglogin.reg@gmail.com
         Resolution|                            |INVALID


--- Comment #1 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-09-13 08:30:35 MSD ---
When calling from C you have to explicitly initialize D's runtime first. Your program calls Phobos function on uninitialized druntime and will obviously crash.

For more information read this: http://stackoverflow.com/questions/7480046/implementing-a-c-api-in-d/7486417#7486417

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------