[llvm-bugs] [Bug 51070] New: Forward declared literal type template arg error
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jul 12 18:11:27 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51070
Bug ID: 51070
Summary: Forward declared literal type template arg error
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: nathan at acm.org
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Created attachment 25018
--> https://bugs.llvm.org/attachment.cgi?id=25018&action=edit
testcase
Using a forward declared literal type in a forward declaration of a template
leads to (at best) a confusing error when the template is defined. Clang claims
the parameter has a different type in the two template declarations. I've not
checked the std, but IMHO either the forward declaration
template<Literal key> struct S;
should be rejected as Literal is incomplete, or the later redeclaration of that
template is valid. Note we don't instantiate S until Literal is defined.
(1)bester:14>bin/clang++ -std=c++20 -c a.cc -DNO_REDECL
bester:15>bin/clang++ -std=c++20 -c a.cc
a.cc:5:18: error: non-type template parameter has incomplete type 'Literal'
template<Literal key> struct S;
^
a.cc:2:8: note: forward declaration of 'Literal'
struct Literal;
^
a.cc:13:18: error: template non-type parameter has a different type 'Literal'
in template redeclaration
template<Literal key>
^
a.cc:5:18: note: previous non-type template parameter with type 'int' is here
template<Literal key> struct S;
^
a.cc:18:6: error: implicit instantiation of undefined template 'S<1>'
S<1> x ;
^
a.cc:5:30: note: template is declared here
template<Literal key> struct S;
^
--
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/20210713/2c1a9efb/attachment.html>
More information about the llvm-bugs
mailing list