www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4710] New: writeln crashes when called from C code.

reply d-bugmail puremagic.com writes:
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



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: -------
Aug 22 2010
parent d-bugmail puremagic.com writes:
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



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:


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