D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 23025 - ImportC: duplicate symbol for tentative definition and definition of variable
Summary: ImportC: duplicate symbol for tentative definition and definition of variable
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Mac OS X
: P1 normal
Assignee: No Owner
URL:
Keywords: ImportC, pull
Depends on:
Blocks:
 
Reported: 2022-04-17 05:59 UTC by dave287091
Modified: 2022-04-19 06:25 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description dave287091 2022-04-17 05:59:05 UTC
The following C program will fail to link with a duplicate symbol error.

```
const char *s; // tentative definition
const char *s = “hello”; // definition
int puts(const char*);
int main(void){
    puts(s);
    return 0
}
```

duplicate symbol '_s' in:
    dup.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
Comment 1 Dlang Bot 2022-04-19 05:21:56 UTC
@WalterBright created dlang/dmd pull request #14010 "fix Issue 23025 - ImportC: duplicate symbol for tentative definition …" fixing this issue:

- fix Issue 23025 - ImportC: duplicate symbol for tentative definition and definition of variable

https://github.com/dlang/dmd/pull/14010
Comment 2 Dlang Bot 2022-04-19 06:25:13 UTC
dlang/dmd pull request #14010 "fix Issue 23025 - ImportC: duplicate symbol for tentative definition …" was merged into master:

- 4c053d5bf3c69db248ffede01c3c808e6c299235 by Walter Bright:
  fix Issue 23025 - ImportC: duplicate symbol for tentative definition and definition of variable

https://github.com/dlang/dmd/pull/14010