This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14513] Friend name injection problem (implicit declaration)
- From: "gdr at integrable-solutions dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Mar 2004 19:55:24 -0000
- Subject: [Bug c++/14513] Friend name injection problem (implicit declaration)
- References: <20040310154252.14513.bugzilla-gcc@thewrittenword.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From gdr at integrable-solutions dot net 2004-03-10 19:55 -------
Subject: Re: Friend name injection problem (implicit declaration)
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| OK, so here's what happens:
| ------------
| struct S {
| void test (void);
| };
|
| namespace NS {
| class X {
| friend class S;
| static int *i;
| };
| }
|
| void S::test () {
| NS::X::i;
| }
| ---------------
| gcc thinks the 'friend class S' declaration refers to class ::S and thus
| allows the access in S::test. All the other compilers seem to believe
| that the friend declaration refer to a yet-to-be-declared class NS::S,
| and therefore don't allow access in ::S::test. I have yet to understand
| what the standard really says in this respect. Kriang?
I'm not Kriang but I'm going to answer. Yes, GCC's behaviour is
wrong. Compilers that reject the code are right. See the explanation
I gave in the link pointed to in the original report. If you want
chapter and verse, see somewhere in 7.3.1.x for namespace members that
talk about friend declarations.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14513