https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96523

            Bug ID: 96523
           Summary: variable templates of constant types have incorrect
                    linkage
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nathan at gcc dot gnu.org
  Target Milestone: ---

Created attachment 49022
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49022&action=edit
testcase part 1

non-template namespace-scope variables of constant type get internal linkage. 
We're doing the same for template-variables, which is wrong.  The attached two
sources should link and run w/o error. The executable returns 2 as the two
instantiations of CONST each has internal linkage.

devvm293:110>./cc1plus var-1_a.C -quiet
devvm293:111>./cc1plus var-1_b.C -quiet
devvm293:112>g++ var-1_*.s
devvm293:113>./a.out                   
(2)devvm293:114>

[basic.link]/3:

A name having namespace scope (6.4.6) has internal linkage if it is the name of

(3.1) — a variable, variable template, function, or function template that is
explicitly declared static; or

(3.2) — a non-template variable of non-volatile const-qualified type, unless

...

[Note: An instantiated variable template that has const-qualified type can have
external or module linkage,
even if not declared extern. — end note]

working on a fix, but would like confirmation of bug

Reply via email to