public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/3894: Template derived from virtual base cannot work with std::vector
@ 2001-08-01  3:54 nathan
  0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2001-08-01  3:54 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, scisim

Synopsis: Template derived from virtual base cannot work with std::vector

State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Wed Aug  1 03:54:50 2001
State-Changed-Why:
    this is fixed in 3.0

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3894&database=gcc


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

* c++/3894: Template derived from virtual base cannot work with std::vector
@ 2001-07-31  4:56 scisim
  0 siblings, 0 replies; 2+ messages in thread
From: scisim @ 2001-07-31  4:56 UTC (permalink / raw)
  To: gcc-gnats

>Number:         3894
>Category:       c++
>Synopsis:       Template derived from virtual base cannot work with std::vector
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 31 04:56:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     SciSim
>Release:        gcc version 2.95.4 20010319 (Debian prerelease)
>Organization:
>Environment:
# default
>Description:
Cannot find copy constructor of derived class, if 
derived class is a template and its base class it virtual.
>How-To-Repeat:
$ cat > Duck.cc
#include <iostream>
#include <vector>

class Duck { 
public: 
  Duck()
  {
    std::cout<<"Constructing a duck\n"; 
  } 

  Duck(const Duck& rhs) 
  {
    std::cout << "Copy constructing a duck\n";
  }
  virtual ~Duck(){}
};

template<class T>
class UncleDagobert : public virtual Duck {
public:
  UncleDagobert() : Duck()
  {
    std::cout<<"Constructing a rich duck\n"; 
  }
  
  UncleDagobert(const UncleDagobert<T> &rhs) : Duck(rhs) 
  {
    std::cout<<"Copy-constructing a rich duck\n";
  }
  UncleDagobert<T >& operator=(const UncleDagobert<T >& rhs) {}
  virtual ~UncleDagobert(){}

};


int main()
{
    UncleDagobert<double> o;
    UncleDagobert<double> oo(o);

    std::vector<UncleDagobert<double > > v;
    v.push_back(o);
    v.push_back(oo);
}
$ g++ Duck.cc
/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3/stl_vector.h: In method `void vector<UncleDagobert<double>,allocator<UncleDagobert<double> > >::_M_insert_aux(UncleDagobert<double> *, const UncleDagobert<double> &)':
/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3/stl_vector.h:325:   instantiated from here
/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3/stl_vector.h:593: no matching function for call to `UncleDagobert<double>::UncleDagobert (const UncleDagobert<double> &)'
Duck.cc:21: candidates are: UncleDagobert<double>::UncleDagobert()
$ 
>Fix:
class UncleDagobert : public Duck
>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2001-08-01  3:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-01  3:54 c++/3894: Template derived from virtual base cannot work with std::vector nathan
  -- strict thread matches above, loose matches on Subject: below --
2001-07-31  4:56 scisim

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).