This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13995] New: Friend declaration with template-id causes confusion of function arguments
- From: "heinlein at informatik dot uni-ulm dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Feb 2004 10:45:03 -0000
- Subject: [Bug c++/13995] New: Friend declaration with template-id causes confusion of function arguments
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following program prints 2 instead of 1, as it should.
It seems that the friend declaration in struct X
causes confusion of the function arguments.
Removing the argument name x in the friend declaration,
produces the error message:
bug.cxx: In function `int f(int, T) [with T = int]':
bug.cxx:8: instantiated from here
bug.cxx:5: `x' undeclared (first use this function)
When the friend declaration is removed, everything is fine.
If struct X is moved before main(), it is fine, too.
Likewise, if the template-id f<int> is replaced with a simple f.
#include <iostream>
using namespace std;
template <typename T>
int f (int x, T y) { return x; }
int main () {
cout << f(1, 2) << endl;
}
struct X {
friend int f<int> (int, int x);
};
--
Summary: Friend declaration with template-id causes confusion of
function arguments
Product: gcc
Version: 3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: heinlein at informatik dot uni-ulm dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13995