This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/29615] New: Class can't be friends of itself?
- From: "danny dot boelens at artwork-systems dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Oct 2006 14:05:56 -0000
- Subject: [Bug c++/29615] New: Class can't be friends of itself?
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following simple C++ file:
<test.cpp>
class A
{
friend class A;
};
int main() { return 0; }
</test.cpp>
results in the following error when I try to compile it with g++:
$ ~/gcc-build-4.2-20061007/gcc/g++ -o test test.cpp
test.cpp:3: error: class 'A' is implicitly friends with itself
I was using a snapshot (GCC 4.2 2006/10/07), but I got the same behaviour with
several 4.1.x and 4.0.x builds on both Linux and Windows 2000 (Cygwin).
I agree that it's pointless to make a class a friend of itself (which is why I
used severity 'minor'), but I haven't found anything in my C++ spec (ISO/IEC
14882) that say it is not allowed. Please point my to the relevant section in
case I missed anything.
By the way: all other compilers I've tried accept this file without a problem.
These include Visual Studio .NET 2003, CodeWarrior 8.3, CodeWarrior 9.6 and the
online test drive for Comeau. Comeau does exactly what I'd expect:
Your Comeau C/C++ test results are as follows:
Comeau C/C++ 4.3.8 (Aug 19 2006 13:36:48) for ONLINE_EVALUATION_Alpha1
Copyright 1988-2006 Comeau Computing. All rights reserved.
MODE:strict errors C++
"ComeauTest.c", line 3: warning: pointless friend declaration
friend class A;
^
Not a big issue, but I thought it might be a good idea to log this anyway,
since a search didn't result in relevant hits :-)
--
Summary: Class can't be friends of itself?
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: danny dot boelens at artwork-systems dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29615