[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug c++/14513] New: namespace problem
From: |
bugzilla-gcc at thewrittenword dot com |
Subject: |
[Bug c++/14513] New: namespace problem |
Date: |
10 Mar 2004 15:42:57 -0000 |
In the process of compiling KDE 3.2 on IRIX 6.5 and Tru64 UNIX 5.1
with the respective vendor C++ compilers, I ran into a namespace
issue. Consider the following:
$ cat a.h
class KMAcctImap;
namespace KIO {
class Job {
public:
int b;
};
}
namespace KMail {
class ImapJob {
friend class KMAcctImap;
public:
ImapJob();
private:
KIO::Job *mJob;
};
}
$ cat b.cpp
namespace KIO {
class Job;
}
namespace KMail {
class ImapJob;
}
using KMail::ImapJob;
class KMAcctImap
{
friend class KMail::ImapJob;
public:
void test (void);
};
#include "a.h"
void KMAcctImap::test (void) {
ImapJob *f = new ImapJob ();
if (f->mJob)
int b;
}
Compile results with different compilers:
(Solaris Sun One 8 compiler)
$ CC -c b.cpp
"b.cpp", line 22: Error: mJob is not accessible from KMAcctImap::test().
1 Error(s) detected.
(HP-UX C++ compiler)
$ aCC -c b.cpp
Error 182: "b.cpp", line 22 # "void KMAcctImap::test()" cannot access
private
member "KIO::Job *KMail::ImapJob::mJob".
if (f->mJob)
^^^^^^^
(IRIX C++ compiler)
$ CC -c b.cpp
cc-1238 CC: ERROR File = b.cpp, Line = 22
The member "KMail::ImapJob::mJob" is inaccessible.
if (f->mJob)
^
(IBM C++ compiler)
$ xlC -c b.cpp
[success]
(Tru64 UNIX C++ compiler)
$ cxx -c b.cpp
cxx: Error: b.cpp, line 22: member "KMail::ImapJob::mJob" is inaccessible
if (f->mJob)
---------^
(GCC 3.3.2 with some patches from 3.3.3 merged in)
$ g++ -c b.cpp
[success]
I can cause a successful compile by changing:
namespace KMail {
class ImapJob {
friend class KMAcctImap;
to:
namespace KMail {
class ImapJob {
friend class ::KMAcctImap;
^^
Based on http://gcc.gnu.org/ml/gcc/2004-03/msg00499.html, GCC is incorrect.
--
Summary: namespace problem
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bugzilla-gcc at thewrittenword dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14513
- [Bug c++/14513] New: namespace problem,
bugzilla-gcc at thewrittenword dot com <=