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

            Bug ID: 67185
           Summary: [concepts] Link error on ODR-use of constexpr
                    constrained variable template partial specialization
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Casey at Carter dot net
  Target Milestone: ---

Created attachment 36170
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36170&action=edit
Test case

r226750 compiles this program compiles correctly:

template <class T>
concept bool C = false;

template <class>
constexpr bool trait = false;

template <C T>
constexpr bool trait<T> = true;

const bool& f() { return trait<int>; }

int main() {}

since it uses the base template, but not this one:

template <class T>
concept bool C = true;

template <class>
constexpr bool trait = false;

template <C T>
constexpr bool trait<T> = true;

const bool& f() { return trait<int>; }

int main() {}

The error is:

~/gcc6-r226750/bin/g++ -std=gnu++1z foo2.cpp
/tmp/ccfAOK5N.o: In function `f()':
foo2.cpp:(.text+0x5): undefined reference to `trait'
collect2: error: ld returned 1 exit status

Inspection of the assembly output (target is Linux x64) shows that the first
program uses the symbol "_Z5traitIiE" for "trait<int>" and the second the
symbol "_ZL5trait". I suspect this discrepancy is the crux of the problem.

Reply via email to