Bug 22537 – importC: Error: undefined reference to 'function' when using static in forward declaration

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-11-23T01:05:50Z
Last change time
2022-09-21T21:54:43Z
Keywords
ImportC, wrong-code
Assigned to
No Owner
Creator
Iain Buclaw
See also
https://issues.dlang.org/show_bug.cgi?id=22538

Comments

Comment #0 by ibuclaw — 2021-11-23T01:05:50Z
static int func(); int main() { return func(); } static int func() { return 0; }
Comment #1 by ibuclaw — 2021-11-23T01:06:33Z
Looking at the output of nm, you can see the function appears twice. 0000000000000000 t func U func 0000000000000000 W main
Comment #2 by bugzilla — 2021-12-10T10:20:47Z
Comment #3 by trikkuz — 2022-04-08T10:18:27Z
The same code using -lib won't work: dmd file.c -lib Error: no definition for static func
Comment #4 by duser — 2022-04-21T14:42:33Z
it works with -lib on stable v2.099.1 but not current git master bisected it to https://github.com/dlang/dmd/pull/13846
Comment #5 by bugzilla — 2022-09-21T21:45:47Z
Please don't reopen fixed bugs with different bugs. It makes the bug list unnecessarily hard to manage.
Comment #6 by bugzilla — 2022-09-21T21:54:43Z