-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
| Bugzilla Link | 11265 |
| Resolution | WORKSFORME |
| Resolved on | Oct 31, 2011 17:11 |
| Version | 2.9 |
| OS | MacOS X |
| Attachments | Reduced test case |
| Reporter | LLVM Bugzilla Contributor |
| CC | @DougGregor,@efriedma-quic |
Extended Description
Compiling the attached file results in a compiler error with Apple clang 3.0 on my Mac OS X 10.6.8 system:
$ clang -Wall -c test3.cc
test3.cc:15:14: error: no matching constructor for initialization of 'A::C<A::b0>'
A::C<A::b0> bar;
^
test3.cc:11:35: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
template <A::B> friend struct A::C;
^
1 error generated.
$ clang -v
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin10.8.0
Thread model: posix
Removing the "friend" statement in struct D, or moving either B or C out of namespace A, as well as all sorts of other minimal changes, gets rid of the error. In particular, replacing the single friend statement by these two works:
friend struct A::C<A::b0>;
friend struct A::C<A::b1>;
If this code is in some way wrong, I fail to see it and would greatly appreciate any pointers as to in which way it is wrong. But then, the mere fact that clang claims that the "friend" statement constitutes a copy constructor makes me think something is very fishy here, even if my code turns out to be somehow flawed.
Note that this is a heavily reduced version of an error that occurred in production code. The original errors are of the form
error: 'N::M::C<1, true>::foo' is not a member of class 'N::M::C<1, true>'
and
error: non-const lvalue reference to type 'N::M::C<1, true>' cannot bind to a value of unrelated type 'N::M::C<1, true>'
where N, M are namespaces and C a class similar to class C in the attached example. Here, too, I identified a single friend statement as "cause" of the problem in the sense that removing it cures the error.