public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14513] New: namespace problem
@ 2004-03-10 15:42 bugzilla-gcc at thewrittenword dot com
  2004-03-10 15:53 ` [Bug c++/14513] " pinskia at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: bugzilla-gcc at thewrittenword dot com @ 2004-03-10 15:42 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2005-01-13 14:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-10 15:42 [Bug c++/14513] New: namespace problem bugzilla-gcc at thewrittenword dot com
2004-03-10 15:53 ` [Bug c++/14513] " pinskia at gcc dot gnu dot org
2004-03-10 16:24 ` [Bug c++/14513] Friend name injection problem (implicit declaration) bangerth at dealii dot org
2004-03-10 19:55 ` gdr at integrable-solutions dot net
2004-08-12  0:58 ` pinskia at gcc dot gnu dot org
2004-09-04 12:47 ` lerdsuwa at gcc dot gnu dot org
2004-10-17 14:08 ` lerdsuwa at gcc dot gnu dot org
2004-11-12 17:03 ` lerdsuwa at gcc dot gnu dot org
2004-11-19 10:10 ` lerdsuwa at gcc dot gnu dot org
2004-11-25 16:55 ` cvs-commit at gcc dot gnu dot org
2004-11-25 17:05 ` lerdsuwa at gcc dot gnu dot org
2005-01-12 19:47 ` pinskia at gcc dot gnu dot org
2005-01-13  0:37 ` giovannibajo at libero dot it
2005-01-13 14:55 ` lerdsuwa 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).