<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 - operator& definition causes unexplained error passing pointer-to-member to template parameter"
href="https://bugs.llvm.org/show_bug.cgi?id=38257">38257</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>operator& definition causes unexplained error passing pointer-to-member to template parameter
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>ambrop7@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The following C++14 program does not compile even though I think it should and
does with GCC.
template<typename>
class enable;
template<typename T, typename = typename enable<T>::enabled>
void operator&(T, T);
template<typename A, typename B, B A::*>
struct Member {};
template<typename>
struct Dummy {};
template<typename X>
struct Bar {
struct Y {
X field;
};
using Useless = Member<Y, X, &Y::field>;
};
template<typename>
struct Foo {
struct Nested;
using FieldType = Bar<Dummy<Nested>>;
FieldType foo_member;
};
template<typename T>
struct Foo<T>::Nested : Member<Foo, FieldType, &Foo::foo_member> {};
Foo<void> foo;
The error is:
prog.cpp:29:54: error: no member 'foo_member' in 'Foo<void>'; it has not yet
been instantiated
struct Foo<T>::Nested : Member<Foo, FieldType, &Foo::foo_member> {};
^
prog.cpp:18:32: note: in instantiation of member class 'Foo<void>::Nested'
requested here
using Useless = Member<Y, X, &Y::field>;
^
prog.cpp:25:13: note: in instantiation of template class
'Bar<Dummy<Foo<void>::Nested> >' requested here
FieldType foo_member;
^
prog.cpp:31:11: note: in instantiation of template class 'Foo<void>' requested
here
Foo<void> foo;
^
prog.cpp:25:13: note: not-yet-instantiated member is declared here
FieldType foo_member;
^
The following changes allow the program to compile:
- Removing the operator& definition or changing it to operator|. (This seems
very strange to me!)
- Removing the definition of Foo<T>::Nested (while leaving the declaration
within Foo).
- Removing "using Useless = ..." within Bar.
The error indicates that Clang is trying to instantiate Foo<void>::Nested due
to the expression &Y::field. This seems unnecessary to me. I think Dummy<X>
should be instantiatable for any X without needing to instantiate X, and as
such it seems inappropriate that Clang is instantiating Foo<void>::Nested.</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>