This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/45515] New: Unable to find base class constructor of templated base class


The following code fails to compile:

template <class T>
class Foo {
 public:
  Foo(int i, int j) {}
};

class Bar : public Foo<int> {
  Bar() : Foo(0, 0) {}
};

This produces the following output:

foo.cc: In constructor ?Bar::Bar()?:
foo.cc:8: error: class ?Bar? does not have any field named ?Foo?
foo.cc:8: error: no matching function for call to ?Foo<int>::Foo()?
foo.cc:4: note: candidates are: Foo<T>::Foo(int, int) [with T = int]
foo.cc:2: note:                 Foo<int>::Foo(const Foo<int>&)

If I change line 8 to "Bar() : Foo<int>(0, 0) {}" it compiles fine. The
original code also compiles fine with clang and comeau. Tested with head gcc,
4.3, and 4.4.


-- 
           Summary: Unable to find base class constructor of templated base
                    class
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andareed at gmail dot com
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]