c++/4003: ICE on template instantiation including friendship declaration.
gdr@codesourcery.com
gdr@codesourcery.com
Sat Aug 11 03:46:00 GMT 2001
>Number: 4003
>Category: c++
>Synopsis: ICE on template instantiation including friendship declaration.
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Sat Aug 11 03:46:05 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Gabriel Dos Reis (gdr@codesourcery.com)
>Release: GCC-3.0.1 and GCC-3.1
>Organization:
>Environment:
Immaterial
>Description:
The below produces an ICE. A regression over gcc-2.95.x
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="sm.C"
Content-Disposition: inline; filename="sm.C"
template<typename> class BinaryTree;
template<typename T>
void move(BinaryTree<T>&, typename BinaryTree<T>::iterator,
BinaryTree<T>&, typename BinaryTree<T>::iterator);
template<class T>
class BinaryTree {
public:
class iterator {
private:
int i;
friend void move<T>(BinaryTree<T> &t1,iterator n1,
BinaryTree<T> &t2,iterator n2);
};
};
template<class T>
inline void move(BinaryTree<T> &t1, typename BinaryTree<T>::iterator n1,
BinaryTree<T> &t2, typename BinaryTree<T>::iterator n2)
{
int x = n1.i + n2.i; // this is the line that uses the friendship
}
int main() {
typedef BinaryTree<int> BT;
BT t;
BT::iterator n;
move(t, n, t, n);
}
More information about the Gcc-bugs
mailing list