public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52379] New: When inheriting a class X from another namespace, inside the class X will always refer to that one.
@ 2012-02-25 11:03 yose at jormy dot com
  2012-02-25 11:26 ` [Bug c++/52379] " yose at jormy dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: yose at jormy dot com @ 2012-02-25 11:03 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52379
           Summary: When inheriting a class X from another namespace,
                    inside the class X will always refer to that one.
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: yose@jormy.com


The attached code should compile, but it does not. GCC thinks "a" inside
Two::B::B() refers to One::A, but it should actually be Two::A instead.

Making Two::B not inherit from One::A removes the problem, so it seems to be
related to inheritance.

If there was class C in namespace One, having the object "C a" inside B::B()
will not work on both cases, so it seems to be only affecting that specific
class name.

thanks to _verty for testing this on 4.6.2 as well, but it existed in 4.3.4 as
well (ideone link : http://ideone.com/TpmpM)


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

* [Bug c++/52379] When inheriting a class X from another namespace, inside the class X will always refer to that one.
  2012-02-25 11:03 [Bug c++/52379] New: When inheriting a class X from another namespace, inside the class X will always refer to that one yose at jormy dot com
@ 2012-02-25 11:26 ` yose at jormy dot com
  2012-02-25 13:59 ` daniel.kruegler at googlemail dot com
  2012-02-25 14:08 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: yose at jormy dot com @ 2012-02-25 11:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Boris von Zuckerberg <yose at jormy dot com> 2012-02-25 11:02:45 UTC ---
Created attachment 26751
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26751
This is the example of the problem in action.


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

* [Bug c++/52379] When inheriting a class X from another namespace, inside the class X will always refer to that one.
  2012-02-25 11:03 [Bug c++/52379] New: When inheriting a class X from another namespace, inside the class X will always refer to that one yose at jormy dot com
  2012-02-25 11:26 ` [Bug c++/52379] " yose at jormy dot com
@ 2012-02-25 13:59 ` daniel.kruegler at googlemail dot com
  2012-02-25 14:08 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-02-25 13:59 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-02-25 13:06:47 UTC ---
The name 'A' within Two::B refers to the base class A (which is One::A), which
again has no what() function. This is essentially the injected-class-name of
the base class as described in the name-lookup of members.

The compiler is correct to reject the code (In addition, the compiler should
also reject the semicolon after the closing brace of the namespaces).


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

* [Bug c++/52379] When inheriting a class X from another namespace, inside the class X will always refer to that one.
  2012-02-25 11:03 [Bug c++/52379] New: When inheriting a class X from another namespace, inside the class X will always refer to that one yose at jormy dot com
  2012-02-25 11:26 ` [Bug c++/52379] " yose at jormy dot com
  2012-02-25 13:59 ` daniel.kruegler at googlemail dot com
@ 2012-02-25 14:08 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-25 14:08 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-25 14:04:38 UTC ---
(In reply to comment #2)
> (In addition, the compiler should
> also reject the semicolon after the closing brace of the namespaces).

That's a long-standing G++ extension, which -pedantic warns about.

Otherwise, agreed, this is invalid.


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

end of thread, other threads:[~2012-02-25 14:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-25 11:03 [Bug c++/52379] New: When inheriting a class X from another namespace, inside the class X will always refer to that one yose at jormy dot com
2012-02-25 11:26 ` [Bug c++/52379] " yose at jormy dot com
2012-02-25 13:59 ` daniel.kruegler at googlemail dot com
2012-02-25 14:08 ` redi at gcc dot gnu.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).