[Bug c++/28332] New: friend classes require explicit qualification when in twin nested namespaces
genixpro at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jul 10 23:35:00 GMT 2006
I do not have a copy of the C++ standard, so I am not sure if this is required
behaviour. However, I do know that G++ gives out a somewhat confusing error
that could be changed. My test case follows all of the other required
information.
The trouble is that G++ doesn't give me an error when I declare class B to be a
friend of class A, instead, it just ignores the declaration altogether unless i
explicitly qualify B to be foo::B, in which case it works.
**G++ version info**
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic --host=i386-redhat-linux
Thread model: posix
**Command line**
g++ testcase.cpp
**Errors**
[bradley@localhost ~]$ g++ testcase.cpp
testcase.cpp: In member function Âvoid foo::B::do_another(foo::bar::A&)Â:
testcase.cpp:20: error: Âvirtual void foo::bar::A::do_something()Â is protected
testcase.cpp:36: error: within this context
**Preproccessed Testcase from -save-temps**
# 1 "testcase.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "testcase.cpp"
namespace foo
{
namespace bar
{
class A;
};
class B;
};
namespace foo
{
namespace bar
{
class A
{
public:
friend class B;
protected:
virtual void do_something()=0;
};
};
class B
{
public:
void do_another(bar::A& a);
};
};
using namespace foo;
using namespace foo::bar;
void B::do_another(A& a)
{
a.do_something();
}
void A::do_something()
{
}
int main ( int argc, char *argv[] )
{
}
--
Summary: friend classes require explicit qualification when in
twin nested namespaces
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: genixpro at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28332
More information about the Gcc-bugs
mailing list