[Issue 21072] New: Segfault reassigning a variable to result of external C function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jul 25 02:26:23 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21072

          Issue ID: 21072
           Summary: Segfault reassigning a variable to result of external
                    C function
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: xdrie at tuta.io

Created attachment 1800
  --> https://issues.dlang.org/attachment.cgi?id=1800&action=edit
source and binaries to reproduce

full source with binaries is attached.
one of them depends on an external C library (i am working on the bindings),
and a prebuilt version is attached, and below are links to the source with
build instructions (very few dependencies, just OpenGL and X11, just a simple
makefile).

source of packages:
- bindings: https://github.com/xdrie/re-raylib-d
- original library (tagged version):
https://github.com/xdrie/raylib/releases/tag/v3.0.0_patch_1

this is the code in `app.d` that causes a segmentation fault on the last line
of main.
```
import raylib;

void main() {
        auto transform_mat = raymath.MatrixIdentity();
        auto top_left = Vector3(1, 1, 0);
        top_left = raymath.Vector3Transform(top_left, transform_mat);
}

```
on the last line, if we assign to a variable, like:
`auto f = raymath.Vector3Transform(top_left, transform_mat);`
then it no longer segfaults.

dmd generates a segfaulting binary; both ldc and gdc generate binaries that
work as expected.

this is why i think this is very likely a dmd bug.

--


More information about the Digitalmars-d-bugs mailing list