D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20627 - Module ctors / dtors should always have D linkage
Summary: Module ctors / dtors should always have D linkage
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-03-03 05:50 UTC by Mathias LANG
Modified: 2020-03-05 05:20 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 Mathias LANG 2020-03-03 05:50:12 UTC
The following code:
```
module oops;
extern(C):

shared static this ()
{
   // Do stuff
}
```

Will emit the shared module constructor as `_sharedStaticDtor_L4_C1`.
Should another module have a similar definition, those functions would conflict.
There is no reason for module constructors / destructors to have C linkage, and its potential for symbol conflict means it should be deprecated.
Comment 1 Dlang Bot 2020-03-03 07:40:44 UTC
@Geod24 created dlang/dmd pull request #10858 "Fix issue 20627: Module ctors / dtors should always have D linkage" fixing this issue:

- Fix issue 20627: Module ctors / dtors should always have D linkage
  
  See the changelog for the rationale of this change (or the issue).

https://github.com/dlang/dmd/pull/10858
Comment 2 Dlang Bot 2020-03-05 04:21:03 UTC
@Geod24 updated dlang/dmd pull request #10834 "Fix issue 20607 - Module constructors are visible as regular function" fixing this issue:

- Fix issue 20627: Module ctors / dtors should always have D linkage
  
  See the changelog for the rationale of this change (or the issue).

https://github.com/dlang/dmd/pull/10834
Comment 3 Dlang Bot 2020-03-05 05:20:32 UTC
dlang/dmd pull request #10858 "Fix issue 20627: Module ctors / dtors should always have D linkage" was merged into master:

- 786fdf10317b25ed5b85ae07e918dc5627b7ab27 by Geod24:
  Fix issue 20627: Module ctors / dtors should always have D linkage
  
  See the changelog for the rationale of this change (or the issue).

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