public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33468]  New: C++: Invalid interpretation of friendness with nested classes
@ 2007-09-18  9:19 gcc-bugzilla at gcc dot gnu dot org
  2007-09-18 18:59 ` [Bug c++/33468] " bangerth at dealii dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2007-09-18  9:19 UTC (permalink / raw)
  To: gcc-bugs


Gcc's friend-mechanism seems to expand to nested classes as well, although
the C++ standard explicitly tells differently.

The following example is almost straight from the C++ standard (11.4/2). The
only change is that inheritance is commented out for class X (in order to
remove the first error in the example). Gcc compiles this with no error
messages, even with -Wall -pedantic

// test.cc
class A {
  class B { };
  friend class X;
};

// INHERITANCE BELOW COMMENTED OUT BY ME
class X /* : A::B */ { // ill-formed: A::B cannot be accessed
  // in the base-clause for X
  A::B mx; // OK: A::B used to declare member of X
  class Y : A::B { // OK: A::B used to declare member of X
// !!!!!!!!!!! The illegal line below compiles fine !!!!!!!!!!
    A::B my; // ill-formed: A::B cannot be accessed
    // to declare members of nested class of X
  };
};

Environment:
System: Linux mustikkakukko 2.6.18.8-0.3-default #1 SMP Tue Apr 17 08:42:35 UTC
2007 x86_64 x86_64 x86_64 GNU/Linux
Architecture: x86_64


host: x86_64-suse-linux-gnu
build: x86_64-suse-linux-gnu
target: x86_64-suse-linux-gnu
configured with: ../gcc-4.2.1/configure --prefix=/usr/local/gcc-4.2.1
--bindir=/usr/local/gcc-4.2.1/bin64 --enable-languages=c,c++
--enable-__cxa_atexit --host=x86_64-suse-linux --with-arch=nocona
--with-tune=nocona

How-To-Repeat:
  g++ -W -Wall -pedantic -c test.cc
  (No errors result in compilation.)


-- 
           Summary: C++: Invalid interpretation of friendness with nested
                    classes
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bitti at iki dot fi
 GCC build triplet: x86_64-suse-linux-gnu
  GCC host triplet: x86_64-suse-linux-gnu
GCC target triplet: x86_64-suse-linux-gnu


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


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

* [Bug c++/33468] C++: Invalid interpretation of friendness with nested classes
  2007-09-18  9:19 [Bug c++/33468] New: C++: Invalid interpretation of friendness with nested classes gcc-bugzilla at gcc dot gnu dot org
@ 2007-09-18 18:59 ` bangerth at dealii dot org
  2007-09-18 19:01 ` [Bug c++/33468] [4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2007-09-18 18:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at dealii dot org  2007-09-18 18:59 -------
Confirmed.

A simpler to understand testcase is this one (all crud removed):
-----------------
class A {
    class B { };
    friend class X;
};
class X {
    A::B mx;
    class Y : A::B {
        A::B my;
    };
};
----------------
It shouldn't compile because X::Y is not a friend and therefore can't
access A::B in the declaration of 'my', as noted in 11.4/2.

This is a regression introduced in gcc 4.0.x. We get the correct error
in everything leading up to 4.0.3, but not any more in 4.0.4. This
may help figure out which patch is at fault...

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |accepts-invalid
      Known to fail|                            |4.0.4 4.1.0 4.2.0
      Known to work|                            |3.3.5 3.4.6 4.0.0 4.0.2
                   |                            |4.0.3
   Last reconfirmed|0000-00-00 00:00:00         |2007-09-18 18:59:43
               date|                            |


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


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

* [Bug c++/33468] [4.1/4.2/4.3 Regression] C++: Invalid interpretation of friendness with nested classes
  2007-09-18  9:19 [Bug c++/33468] New: C++: Invalid interpretation of friendness with nested classes gcc-bugzilla at gcc dot gnu dot org
  2007-09-18 18:59 ` [Bug c++/33468] " bangerth at dealii dot org
@ 2007-09-18 19:01 ` pinskia at gcc dot gnu dot org
  2007-09-28  4:07 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-09-18 19:01 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|x86_64-suse-linux-gnu       |
   GCC host triplet|x86_64-suse-linux-gnu       |
 GCC target triplet|x86_64-suse-linux-gnu       |
            Summary|C++: Invalid interpretation |[4.1/4.2/4.3 Regression]
                   |of friendness with nested   |C++: Invalid interpretation
                   |classes                     |of friendness with nested
                   |                            |classes
   Target Milestone|---                         |4.1.3


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


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

* [Bug c++/33468] [4.1/4.2/4.3 Regression] C++: Invalid interpretation of friendness with nested classes
  2007-09-18  9:19 [Bug c++/33468] New: C++: Invalid interpretation of friendness with nested classes gcc-bugzilla at gcc dot gnu dot org
  2007-09-18 18:59 ` [Bug c++/33468] " bangerth at dealii dot org
  2007-09-18 19:01 ` [Bug c++/33468] [4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
@ 2007-09-28  4:07 ` mmitchel at gcc dot gnu dot org
  2007-11-10 20:34 ` simartin at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-09-28  4:07 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


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

* [Bug c++/33468] [4.1/4.2/4.3 Regression] C++: Invalid interpretation of friendness with nested classes
  2007-09-18  9:19 [Bug c++/33468] New: C++: Invalid interpretation of friendness with nested classes gcc-bugzilla at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-09-28  4:07 ` mmitchel at gcc dot gnu dot org
@ 2007-11-10 20:34 ` simartin at gcc dot gnu dot org
  2007-11-12 19:42 ` janis at gcc dot gnu dot org
  2007-11-12 22:05 ` jason at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: simartin at gcc dot gnu dot org @ 2007-11-10 20:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from simartin at gcc dot gnu dot org  2007-11-10 20:33 -------
For information, the compiler accepts this because it implements DR 45
(http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#45).

It looks like the implementation has been in for a long time, but the it did
not work completely, and it was fixed to fix PR#18681. This could explain why
this code was accepted up to 4.0.3.


-- 

simartin at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simartin at gcc dot gnu dot
                   |                            |org


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


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

* [Bug c++/33468] [4.1/4.2/4.3 Regression] C++: Invalid interpretation of friendness with nested classes
  2007-09-18  9:19 [Bug c++/33468] New: C++: Invalid interpretation of friendness with nested classes gcc-bugzilla at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-11-10 20:34 ` simartin at gcc dot gnu dot org
@ 2007-11-12 19:42 ` janis at gcc dot gnu dot org
  2007-11-12 22:05 ` jason at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: janis at gcc dot gnu dot org @ 2007-11-12 19:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from janis at gcc dot gnu dot org  2007-11-12 19:42 -------
On the 4.0 branch, the behavior of the test changed with:

    http://gcc.gnu.org/viewcvs?view=rev&rev=115209

    r115209 | jason | 2006-07-05 20:40:06 +0000 (Wed, 05 Jul 2006)


-- 

janis at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


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


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

* [Bug c++/33468] [4.1/4.2/4.3 Regression] C++: Invalid interpretation of friendness with nested classes
  2007-09-18  9:19 [Bug c++/33468] New: C++: Invalid interpretation of friendness with nested classes gcc-bugzilla at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-11-12 19:42 ` janis at gcc dot gnu dot org
@ 2007-11-12 22:05 ` jason at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu dot org @ 2007-11-12 22:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jason at gcc dot gnu dot org  2007-11-12 22:05 -------
Not a bug under DR 45.


-- 

jason at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-11-12 22:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-18  9:19 [Bug c++/33468] New: C++: Invalid interpretation of friendness with nested classes gcc-bugzilla at gcc dot gnu dot org
2007-09-18 18:59 ` [Bug c++/33468] " bangerth at dealii dot org
2007-09-18 19:01 ` [Bug c++/33468] [4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
2007-09-28  4:07 ` mmitchel at gcc dot gnu dot org
2007-11-10 20:34 ` simartin at gcc dot gnu dot org
2007-11-12 19:42 ` janis at gcc dot gnu dot org
2007-11-12 22:05 ` jason 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).