[Bug c++/90493] const variable template specialization is always local

herring at lanl dot gov gcc-bugzilla@gcc.gnu.org
Mon Aug 23 15:11:48 GMT 2021


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

--- Comment #4 from S. Davis Herring <herring at lanl dot gov> ---
(In reply to Jonathan Wakely from comment #3)
> Reduced to show just the rejects-valid part:
> 
> template <typename T> extern const int foo = 41;
> // this is an error:
> // error: explicit template specialization cannot have a storage class
> template <> extern const int foo<int> = 42;

This code is ill-formed ([temp.expl.spec]/2) and is nonsensical because linkage
doesn't pertain to template specializations ([temp.type]/1).  (Obviously at the
assembly level there are global and local symbols for certain template
specializations, but their status is determined by the linkage of the template
and sometimes by the template arguments.)

As such, I'm not sure this is distinct from 96523.


More information about the Gcc-bugs mailing list