public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/25863]  New: Allowed knowledge of private structure.
@ 2006-01-19 19:11 v13 at it dot teithe dot gr
  2006-03-08  5:04 ` [Bug c++/25863] " bangerth at dealii dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: v13 at it dot teithe dot gr @ 2006-01-19 19:11 UTC (permalink / raw)
  To: gcc-bugs

This piece of code:

------------------------------------------------
#include <iostream>

using namespace std;

class A
{
 private: class B {public: int l;};
 public: B getB() { B b; return (b); }
};

int main()
{
        A       a;
        cout << a.getB().l;
}
------------------------------------------------

Compiles fine. The questions are:
Should the main() know that the return type of getB() contains an element named
l? - How the code in main() knows about the structure of A::B ?
Is there any difference from allowing an A::B object declared in main()?

Tested with:
g++ (GCC) 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)
g++ (GCC) 3.3.5 (Debian 1:3.3.5-13)
g++ 2.95.4

Also tested with IRIX SGI CC 6.5 and C++ from Visual Studio 6.0 and it compiled
there too...

Sorry if this is not a bug.


-- 
           Summary: Allowed knowledge of private structure.
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: v13 at it dot teithe dot gr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25863


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

* [Bug c++/25863] Allowed knowledge of private structure.
  2006-01-19 19:11 [Bug c++/25863] New: Allowed knowledge of private structure v13 at it dot teithe dot gr
@ 2006-03-08  5:04 ` bangerth at dealii dot org
  2006-05-26 15:38 ` bangerth at dealii dot org
  2006-07-30 10:24 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2006-03-08  5:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at dealii dot org  2006-03-08 05:04 -------
This is how it is supposed to be. Note that access control (i.e. whether
you can or cannot use a name) is not implemented by "hiding" the name.
The name of private members is always available, you may simply not
access it (unless you're a friend or member).

W.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25863


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

* [Bug c++/25863] Allowed knowledge of private structure.
  2006-01-19 19:11 [Bug c++/25863] New: Allowed knowledge of private structure v13 at it dot teithe dot gr
  2006-03-08  5:04 ` [Bug c++/25863] " bangerth at dealii dot org
@ 2006-05-26 15:38 ` bangerth at dealii dot org
  2006-07-30 10:24 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2006-05-26 15:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bangerth at dealii dot org  2006-05-26 15:38 -------
As mentioned before, this is legal code.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25863


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

* [Bug c++/25863] Allowed knowledge of private structure.
  2006-01-19 19:11 [Bug c++/25863] New: Allowed knowledge of private structure v13 at it dot teithe dot gr
  2006-03-08  5:04 ` [Bug c++/25863] " bangerth at dealii dot org
  2006-05-26 15:38 ` bangerth at dealii dot org
@ 2006-07-30 10:24 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-07-30 10:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-07-30 10:24 -------
*** Bug 28539 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dushistov at mail dot ru


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25863


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

end of thread, other threads:[~2006-07-30 10:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-19 19:11 [Bug c++/25863] New: Allowed knowledge of private structure v13 at it dot teithe dot gr
2006-03-08  5:04 ` [Bug c++/25863] " bangerth at dealii dot org
2006-05-26 15:38 ` bangerth at dealii dot org
2006-07-30 10:24 ` pinskia 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).