From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20175 invoked by alias); 21 Mar 2006 22:10:34 -0000 Received: (qmail 20167 invoked by uid 22791); 21 Mar 2006 22:10:33 -0000 X-Spam-Check-By: sourceware.org Received: from mail11.bluewin.ch (HELO mail11.bluewin.ch) (195.186.18.61) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 21 Mar 2006 22:10:32 +0000 Received: from [192.168.1.65] (81.62.197.73) by mail11.bluewin.ch (Bluewin 7.2.071) id 441EA17C000770EC for gcc-help@gcc.gnu.org; Tue, 21 Mar 2006 22:10:29 +0000 Mime-Version: 1.0 (Apple Message framework v746.3) In-Reply-To: <20060321191652.GA16616@rodsoft.org> References: <20060321191652.GA16616@rodsoft.org> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: =?ISO-8859-1?Q?Daniel_Llorens_del_R=EDo?= Subject: Re: function template specialization problem Date: Tue, 21 Mar 2006 22:10:00 -0000 To: gcc-help@gcc.gnu.org X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-03/txt/msg00145.txt.bz2 On 21 Mar, 2006, at 20:16, rodolfo@rodsoft.org wrote: > Hi, I don't know if this is a C++ or g++ problem, but this snippet > doesn't compile, but I think it should: > > template void test(const char *par); > > template <> void test(const char *par = 0) {} > > int main() > { > test(); > } > > g++ 3.4.5 returns the following errors: > test.cpp:3: error: default arguments are only permitted for > function parameters > test.cpp:7: error: no matching function for call to `test()' The first error message is unclear, but the code is illegal anyway. You cannot declare a default parameter in a specialization. You must declare it in the function template declaration, and only there.