public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
[parent not found: <bug-19249-2828@http.gcc.gnu.org/bugzilla/>]
* [Bug c++/19249] New: abstract classes should not access virtually inherited class constructor
@ 2005-01-04  5:36 gianni at mariani dot ws
  2005-01-04  5:42 ` [Bug c++/19249] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: gianni at mariani dot ws @ 2005-01-04  5:36 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]

Since abstract classes cannot be instantiated without being derived, any
classes inherited virtually in an abstract class cannot have their
constructor called by the abstract class constuctor hence the abstract
class constructor must not reference the constructor of any virtually
inherited class.

Discussion on comp.std.c++ :
http://groups-beta.google.com/group/comp.std.c++/browse_thread/thread/0d8cf2d93117bfa1#3f6fda6a03cb5c6a

Diagnostics :

/gcc/gcc-4.0-20041128-build/bin/g++ -o xx virt_inhr_vcbug.cpp
virt_inhr_vcbug.cpp: In constructor ‘Interface::Interface()’:
virt_inhr_vcbug.cpp:4: error: ‘controller::controller()’ is private
virt_inhr_vcbug.cpp:22: error: within this context

Code:

class controller
{
    controller(); // private don't want anyone to call this
    public:
    controller( int ); // this should be called instead
};
 
class Interface
  : virtual public controller
{
    public:
    virtual void DoThing() = 0;
};
 
 
class Application
  : public Interface
{
    public:
    Application()
      : controller( 3 )
    {
    }
 
    void DoThing()
    {
        // Doing it here !
    }
};

-- 
           Summary: abstract classes should not access virtually inherited
                    class constructor
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gianni at mariani dot ws
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2021-12-08  8:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-19249-4@http.gcc.gnu.org/bugzilla/>
2021-12-08  7:56 ` [Bug c++/19249] abstract classes should not access virtually inherited class constructor pinskia at gcc dot gnu.org
2021-12-08  8:03 ` pinskia at gcc dot gnu.org
     [not found] <bug-19249-2828@http.gcc.gnu.org/bugzilla/>
2006-11-04 15:34 ` jens dot maurer at gmx dot net
2006-11-04 15:44 ` jens dot maurer at gmx dot net
2005-01-04  5:36 [Bug c++/19249] New: " gianni at mariani dot ws
2005-01-04  5:42 ` [Bug c++/19249] " pinskia at gcc dot gnu dot org
2005-01-04  9:15 ` pinskia at gcc dot gnu dot org
2005-01-05 14:30 ` jkanze at cheuvreux dot com
2005-01-14  3:00 ` gianni at mariani dot ws
2005-01-14  3:08 ` pinskia at gcc dot gnu dot org
2005-01-14  6:47 ` gianni at mariani dot ws
2005-05-01  2:51 ` pinskia at gcc dot gnu dot org
2005-07-23 20:07 ` bangerth at dealii 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).