www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22897] New: importC: segfault calling forward-declared static

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

          Issue ID: 22897
           Summary: importC: segfault calling forward-declared static
                    function through pointer
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Keywords: ImportC, wrong-code
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: duser neet.fi

static void other(void);
int main()
{
        void (*fn)(void) = other;
        fn();
        return 0;
}
static void other(void)
{
}

happens on linux but not windows

- direct calls work but taking the address gives an invalid pointer
- only functions that come before the body of other() are affected

--
Mar 17 2022