From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14349 invoked by alias); 19 Aug 2008 15:35:13 -0000 Received: (qmail 14337 invoked by uid 22791); 19 Aug 2008 15:35:13 -0000 X-Spam-Check-By: sourceware.org Received: from an-out-0708.google.com (HELO an-out-0708.google.com) (209.85.132.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 19 Aug 2008 15:34:38 +0000 Received: by an-out-0708.google.com with SMTP id c28so409ana.104 for ; Tue, 19 Aug 2008 08:34:36 -0700 (PDT) Received: by 10.100.93.19 with SMTP id q19mr1068586anb.37.1219160076326; Tue, 19 Aug 2008 08:34:36 -0700 (PDT) Received: by 10.100.232.19 with HTTP; Tue, 19 Aug 2008 08:34:36 -0700 (PDT) Message-ID: <9c1eb01c0808190834p147266b8w2ae6224ee49689b9@mail.gmail.com> Date: Tue, 19 Aug 2008 15:37:00 -0000 From: "Michael Kaes" To: gcc-help@gcc.gnu.org Subject: Template type usage from base classes MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_31712_22756640.1219160076326" Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00168.txt.bz2 ------=_Part_31712_22756640.1219160076326 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 1798 Hi, I am having some problems with a template structure I am using and was hoping that someone around here could give me a hint. The code I am using works fine on the Visual Studio 8 compiler from MS but it does not compile on the gcc. I stripped it down as good as I could and it looks valid to me but still it only compiles with VS8 and not with the GCC. The interesting thing is that it does work when I only use one template parameter. I am using gcc version 4.2.4 (Debian 4.2.4-3). Could this be a bug in the gcc or is this simply not valid c++ code and the VS8 is only generous? The stripped down example: #include template< size_t sizeValue, typename NumericType> class Base { protected: NumericType n; public: typedef NumericType val_t; Base(val_t t):n(t) { } }; template< size_t sizeValue, typename unusedType > class Derived; template< size_t sizeValue > class Derived : public Base { public: Derived() : Base(1) { } }; int main() { Derived<12, int> d; } The error message I get is the following templateTest.cpp: In constructor Derived::Derived(): templateTest.cpp:32: error: val_t was not declared in this scope templateTest.cpp:32: error: template argument 2 is invalid templateTest.cpp: In constructor Derived::Derived() [with unsigned int sizeValue = 12u]: templateTest.cpp:39: instantiated from here templateTest.cpp:32: error: no matching function for call to Base<12u, int>::Base() templateTest.cpp:13: note: candidates are: Base::Base(NumericType) [with unsigned int sizeValue = 12u, NumericType = int] templateTest.cpp:7: note: Base<12u, int>::Base(const Base<12u, int>&) Thanks in advance Michael Kaes ------=_Part_31712_22756640.1219160076326 Content-Type: text/plain; name=templateIssue.cpp Content-Transfer-Encoding: base64 X-Attachment-Id: f_fk2o1pi20 Content-Disposition: attachment; filename=templateIssue.cpp Content-length: 655 I2luY2x1ZGU8aW9zdHJlYW0+DQoNCnRlbXBsYXRlPA0KCXNpemVfdCBzaXpl VmFsdWUsDQoJdHlwZW5hbWUgTnVtZXJpY1R5cGU+DQpjbGFzcyBCYXNlDQp7 DQoJcHJvdGVjdGVkOg0KCQlOdW1lcmljVHlwZSBuOw0KCXB1YmxpYzoNCgkJ dHlwZWRlZiBOdW1lcmljVHlwZSB2YWxfdDsNCg0KCQlCYXNlKHZhbF90IHQp Om4odCkNCgkJew0KCQl9DQp9Ow0KDQoNCnRlbXBsYXRlPA0KCXNpemVfdCBz aXplVmFsdWUsDQoJdHlwZW5hbWUgdW51c2VkVHlwZQ0KPg0KY2xhc3MgRGVy aXZlZDsNCg0KDQp0ZW1wbGF0ZTwNCglzaXplX3Qgc2l6ZVZhbHVlDQo+DQpj bGFzcyBEZXJpdmVkPHNpemVWYWx1ZSwgaW50PiA6IHB1YmxpYyBCYXNlPHNp emVWYWx1ZSwgaW50Pg0Kew0KCXB1YmxpYzoNCgkJRGVyaXZlZCgpIDogQmFz ZTxzaXplVmFsdWUsIHZhbF90PigxKQ0KCQl7DQoJCX0NCn07DQoNCmludCBt YWluKCkNCnsNCglEZXJpdmVkPDEyLCBpbnQ+IGQ7DQp9 ------=_Part_31712_22756640.1219160076326--