https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99914
Bug ID: 99914 Summary: d: Template symbols not overridable by normal symbols Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: d Assignee: ibuclaw at gdcproject dot org Reporter: ibuclaw at gdcproject dot org Target Milestone: --- Currently, the following does not link: extern(C) __gshared bool rt_cmdline_enabled = false; Because the symbol conflicts with a template symbol of the same name in the D runtime library. template rt_cmdline_enabled() { pragma(mangle, "rt_cmdline_enabled") __gshared bool rt_cmdline_enabled = true; } Template symbols are made DECL_ONE_ONLY, which ends up in the gnu.linkonce section as a unique global symbol. However, the linker only considers other symbols in gnu.linkonce as being candidates for discarding duplicates. The expected and correct behaviour is for all instantiations to be declared weak.