From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29705 invoked by alias); 1 Mar 2013 08:52:00 -0000 Received: (qmail 29686 invoked by uid 22791); 1 Mar 2013 08:51:59 -0000 X-SWARE-Spam-Status: No, hits=-8.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Mar 2013 08:51:51 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r218poFe017527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Mar 2013 03:51:51 -0500 Received: from oldenburg.str.redhat.com (oldenburg.str.redhat.com [10.33.200.60]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r218pmBl025935 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 1 Mar 2013 03:51:49 -0500 Message-ID: <51306C23.3090509@redhat.com> Date: Fri, 01 Mar 2013 08:52:00 -0000 From: Florian Weimer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3 MIME-Version: 1.0 To: Ulrich Drepper CC: Benjamin De Kosnik , =?UTF-8?B?RGFuaWVsIEtyw7xnbGVy?= , "libstdc++@gcc.gnu.org" , GCC Patches Subject: Re: [PATCH] C++ math constants References: <20130221093859.33b4d2fe@oakwood> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2013-03/txt/msg00005.txt.bz2 On 03/01/2013 05:15 AM, Ulrich Drepper wrote: > On Thu, Feb 21, 2013 at 12:38 PM, Benjamin De Kosnik wrote: >> Not seeing it. >> >> Say for: >> >> #include >> >> // A class for math constants. >> template >> struct __math_constants >> { >> // Constant @f$ \pi @f$. >> static constexpr _RealType __pie = >> 3.1415926535897932384626433832795029L; }; >> >> template >> void print(const T& t) { std::cout << t; } >> >> int main() >> { >> print(__math_constants::__pie); >> return 0; >> } >> >> I'm not getting any definition, even at -O0. > > Even more so: how would an explicit instantiation even work? You don't need an explicit instantiation, just a regular templated definition. This example shows that a definition is needed, and how one is provided. template struct a { static constexpr T m = T(1); }; template constexpr T a::m; const int * f() { return &a::m; } int main() { return f() == 0; } -- Florian Weimer / Red Hat Product Security Team