[llvm-bugs] [Bug 28816] Missing error on explicit instantiation definition of undefined variable template

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 3 07:11:02 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=28816

John Brawn <john.brawn at arm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #1 from John Brawn <john.brawn at arm.com> ---
"template<int n> int var" is actually a definition of a template variable (with
an implicit initialization to zero), so the compiler's behaviour here is fine.
If you do "template<int n> extern int var" then that _is_ a declaration, and in
that case we get the error

tmp.cpp:2:14: error: explicit instantiation of undefined variable template
'var<0>'
template int var<0>;
             ^
tmp.cpp:1:28: note: explicit instantiation refers here
template<int n> extern int var;
                           ^
1 error generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200303/8945e679/attachment.html>


More information about the llvm-bugs mailing list