This is the mail archive of the gcc-bugs@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]

C++ namespace::class can't be friends with main()



Possibly I'm being really stupid.  But I'm pretty sure the following
is a bug.  main() should be able to access the protected constructor
since it is a friend.  (Note: I've also run into other problems making
functions friends, but this is the only one that I'm sure isn't my
error!) 

thanks,

dean
-----------------------------------------------------------------------

namespace foo
{
  class bar
  {
  protected:
    bar();
  private:
    friend int main();  // should make main() a friend
                        // note: "friend int ::main()"  doesn't work either
                        // pre-declaring main doesn't help
  };

}
 
int
main()
{
  foo::bar x;
}
-----------------------------------------------------------------------
output:
friends.cc: In function `int main()':
friends.cc:8: `foo::bar::bar()' is protected
friends.cc:18: within this context
-----------------------------------------------------------------------
version:
Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
-----------------------------------------------------------------------


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