From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23101 invoked by alias); 28 Aug 2012 15:32:42 -0000 Received: (qmail 23088 invoked by uid 22791); 28 Aug 2012 15:32:41 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Aug 2012 15:32:26 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1T6NmF-0006Ia-54 for gcc-help@gcc.gnu.org; Tue, 28 Aug 2012 17:32:27 +0200 Received: from dra38-5-82-246-248-175.fbx.proxad.net ([82.246.248.175]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 28 Aug 2012 17:32:27 +0200 Received: from cwg by dra38-5-82-246-248-175.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 28 Aug 2012 17:32:27 +0200 To: gcc-help@gcc.gnu.org From: Christoph Groth Subject: (undocumented?) difference between gcc 4.6 and 4.7 (C++ implicit template instantiation) Date: Tue, 28 Aug 2012 17:24:00 -0000 Message-ID: <87vcg3c9rz.fsf@falma.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) X-IsSubscribed: yes 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: 2012-08/txt/msg00282.txt.bz2 Dear GCC experts, While developing a Python extension using CPython's C API in C++ I've encountered a situation where a program compiles with GCC 4.7.1 but does not compile with 4.6.3. I have attached a minimal program demonstrating the problem. As a workaround, adding a explicit instantiation makes the program also compile under GCC 4.6. I've been unable to find a description of this issue in any changelog. Actually, I wonder whether the behavior of 4.6 or that of 4.7 is the correct one with regard to the C++ language standard. Is this a known issue which has been fixed in 4.7, or rather a regression from 4.6? // Compile with: g++ test.cc typedef void *(*Func)(void *); template class Class { public: static Func hoho; }; template void *something(Class *self) { } // The following line makes it compile under GCC 4.6 // template void *something(Class*); template Func Class::hoho = (Func)something; // Explicit instantiation. This does instantiate something // under GCC 4.7 but not under GCC 4.6. template class Class; int main() { Class::hoho(0); }