This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ language lawyer question


Gerald Pfeifer <gerald@pfeifer.com> writes:

| Current mainline issues the following error
| 
|   x.cc:2: error: `void A::a()' is private
|   x.cc:6: error: within this context
| 
| for this snippet:
| 
|   class A {
|      void a();
|   };
| 
|   class B {
|      friend void A::a();
|   };
| 
| I'm not a language lawyer, but is this really correct? (Intuitively, it
| seems quite backwards.)

Gerald --

  Despite what has been claimed about the simplicy of the issue, it is
not as clear cut some would like to believe.  Exactly the issue you're
raising has been a subject of a DR, and although it has been decided
to resolve it as a NAD, it is highly instructive to read

  http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#209


What is amusing is the rationale for resolving the issue as a NAD:

  Ultimately it was decided that the original perceived defect was not
  sufficiently serious as to warrant the degree of complexity required
  to resolve it satisfactorily and the issue was consequently declared
  not to be a defect. It was observed that most of the problems
  involved with the current state of affairs result from inability to
  declare a particular member function as a friend; in such cases, an
  easy workaround is simply to befriend the entire class rather than
  the specific member function.   

I believe your addition to changes.html should include that link.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]