From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12437 invoked by alias); 10 Jul 2009 11:48:31 -0000 Received: (qmail 12413 invoked by uid 22791); 10 Jul 2009 11:48:25 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=BAYES_00,J_CHICKENPOX_13,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-fx0-f222.google.com (HELO mail-fx0-f222.google.com) (209.85.220.222) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Jul 2009 11:48:19 +0000 Received: by fxm22 with SMTP id 22so778488fxm.8 for ; Fri, 10 Jul 2009 04:48:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.127.8 with SMTP id e8mr919617fas.80.1247226496399; Fri, 10 Jul 2009 04:48:16 -0700 (PDT) Date: Fri, 10 Jul 2009 11:48:00 -0000 Message-ID: <4d623d70907100448g529a565qc64371440c15a7c8@mail.gmail.com> Subject: Possible bug in g++ - template specialization From: Maciej Cencora To: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg00185.txt.bz2 Hi, I think I've found a bug in g++. Let's say we have following files: // a.hpp template void func1() { // general code } // a.cpp #include "a.hpp" template<> void func1() { // specialized code } // main.cpp #include "a.hpp" int main(void) { func1(); return 0; } Now when we run the program compiled with: g++ main.cpp a.cpp -o main specialized version of func1 will be called, but when compiled with -Os flag the general version will be called. I'm not an expert but I believe the -Os behaviour is the correct one. Please CC me when replying, as I'm not subscribed to the mailing list. Regards, Maciej Cencora