From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14542 invoked by alias); 1 Jul 2011 18:56:56 -0000 Received: (qmail 14527 invoked by uid 22791); 1 Jul 2011 18:56:55 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Jul 2011 18:56:41 +0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/49609] No code emitted for address-taken instances of function templates X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Fri, 01 Jul 2011 18:56:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg00082.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49609 --- Comment #5 from Jonathan Wakely 2011-07-01 18:56:19 UTC --- (In reply to comment #3) > That's a pretty strained reading. Even if that were pedantically what the > standard says, it would clearly be an oversight. ok, good! I would have assumed it was meant to work except that clang gives exactly the same behaviour, so I started looking for reasons why. (In reply to comment #4) > > You can also make it work by not specifying an explicit template argument list > > and letting them be deduced: > > > > void *(*my_function_ptr)(void*, void *) > > = reinterpret_cast( > > (void*(*)(float*,float*))&value_convert_function); > > Cool -- thanks for this! That teaches me for thinking I can get away without > ever using C-style casts in C++.... You can do it without -style casts, using static_cast: void *(*my_function_ptr)(void*, void *) = reinterpret_cast( static_cast(&value_convert_function)); or with a functional-style cast: typedef void*(*func_type)(float*,float*); void *(*my_function_ptr)(void*, void *) = reinterpret_cast( func_type(&value_convert_function));