This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/70095] New: [C++14] Link error on partially specialized variable template


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

            Bug ID: 70095
           Summary: [C++14] Link error on partially specialized variable
                    template
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldionne.2 at gmail dot com
  Target Milestone: ---

The following code fails to link on GCC trunk:

    template <typename T> struct Foo;
    template <typename T> int variable_template         = 0;
    template <typename T> int variable_template<Foo<T>> = 0;
    template <typename T> int get_variable_template() { return
variable_template<T>; }

    int main() {
        get_variable_template<Foo<int>>();
    }


> ~/code/gcc/prefix/bin/g++ -std=c++14 test/worksheet.cpp

    Undefined symbols for architecture x86_64:
      "_variable_template", referenced from:
          int get_variable_template<Foo<int> >() in ccPzxGMc.o
         (maybe you meant: int get_variable_template<Foo<int> >())
    ld: symbol(s) not found for architecture x86_64
    collect2: error: ld returned 1 exit status


Live example: http://melpon.org/wandbox/permlink/eFOhrTWIfIeelZnu


Curiously, explicitly specializing `variable_template<Foo<int>>` fixes the
issue.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]