<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Forward declared literal type template arg error"
href="https://bugs.llvm.org/show_bug.cgi?id=51070">51070</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Forward declared literal type template arg error
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++2a
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nathan@acm.org
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=25018" name="attach_25018" title="testcase">attachment 25018</a> <a href="attachment.cgi?id=25018&action=edit" title="testcase">[details]</a></span>
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;
^</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>