<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 - C++ friend Constructor with Templates Not Recognized"
href="https://bugs.llvm.org/show_bug.cgi?id=38578">38578</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>C++ friend Constructor with Templates Not Recognized
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mattmiller1@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Noticed the following behavior which isn't clear to me is standard compliant:
1. non-template friend function (not constructor): compiles in gcc and clang
2. non-template friend constructor: compiles in gcc and clang
3. template friend function (not constructor): compiles in gcc and clang
4. template friend constructor: compiles in gcc , but not clang
(compiled in clang 3.0.0 but not clang 3.1+)
Here is an example (use -DUSE_TEMPLATE to control whether the template
or non-template code is compiled):
<a href="https://godbolt.org/g/FT7Mzj">https://godbolt.org/g/FT7Mzj</a>
In the clang case for (4), it gives an error as if the friend
declaration was never made.
Looking at a C++ standard:
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf</a>
It looks like section 14.3.5 gives an explicit example of a
non-template friend constructor being allowed. In 17.5.4, it didn't
look like there was anything to indicate template friend constructors
are treated different than template friend non-constructor functions,
but maybe I'm missing a subtle point in that section or elsewhere.
If there is a reason why (4) is not allowed by the standard but (3)
is, it might be good to have a more specific compile error message
indicating that.</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>