public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27123] New: friend class declaration doesn't search out of the namespace
@ 2006-04-11 18:52 pvuorela at iki dot fi
2006-04-11 18:56 ` [Bug c++/27123] " pinskia at gcc dot gnu dot org
2007-05-09 22:10 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: pvuorela at iki dot fi @ 2006-04-11 18:52 UTC (permalink / raw)
To: gcc-bugs
G++ does not seem to search for classes for friend class declaration outside
the current namespace.
The following code does not work with G++ 4.0.3/4.1.0.
----
class bar;
namespace NS
{
class foo
{
private:
friend class bar;
static int var;
};
int foo::var = 0;
}
class bar
{
public:
bar()
{
NS::foo::var = 1;
}
};
int main()
{
bar i;
}
-------
Result is:
nstest.cc: In constructor 'bar::bar()':
nstest.cc:12: error: 'int NS::foo::var' is private
nstest.cc:21: error: within this context
The above code works with g++ 3.4.4.
A work around for 4.x is defining friend class as "::bar".
gcc -v:
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,fortran,objc,obj-c++,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre --enable-mpfr
--with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.0 (Debian 4.1.0-1)
System:
Linux maestro 2.6.16 #1 SMP PREEMPT Mon Mar 20 21:20:19 EET 2006 i686 GNU/Linux
--
Summary: friend class declaration doesn't search out of the
namespace
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pvuorela at iki dot fi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27123
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-09 22:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-11 18:52 [Bug c++/27123] New: friend class declaration doesn't search out of the namespace pvuorela at iki dot fi
2006-04-11 18:56 ` [Bug c++/27123] " pinskia at gcc dot gnu dot org
2007-05-09 22:10 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).