www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22732] New: Header generator should export the function

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

          Issue ID: 22732
           Summary: Header generator should export the function attributes
                    by inferring them whenever possible
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: contact lsferreira.net

```
int[] sysfunc()  system
{
    // unsafe code
    import core.stdc.stdlib : malloc;
    auto p = cast(int*) malloc(5 * int.sizeof);
    return p[0 .. 5];
}

struct S {
    int[] bar() {
        return sysfunc();
    }
}
```

The generated header file doesn't infer `S.bar()` attributes and therefore
exporting the wrong signature.

--
Feb 03 2022