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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It looks like explicit specializations are not given vague linkage. Is that the
correct behaviour?

/usr/bin/ld: /tmp/ccjbP7xI.o:/tmp/t.h:2: multiple definition of `var<int>';
/tmp/ccMCRAVO.o:/tmp/t.h:2: first defined here


Given these two TUs:

template<typename T> constexpr bool var = true;
template<> constexpr bool var<int> = false;
bool foo();
int main() { return var<int> != foo(); }

template<typename T> constexpr bool var = true;
template<> constexpr bool var<int> = false;
bool foo() { return var<int>; }


It works if I add 'inline' to the explicit specialization.

Reply via email to