Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 6025 invoked from network); 3 Aug 2007 01:08:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Aug 2007 01:08:58 -0000 Received: (qmail 6919 invoked by uid 500); 3 Aug 2007 01:08:57 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 6911 invoked by uid 500); 3 Aug 2007 01:08:57 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 6900 invoked by uid 99); 3 Aug 2007 01:08:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Aug 2007 18:08:57 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.quovadx.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2007 01:08:52 +0000 Received: from qxvcexch01.ad.quovadx.com ([192.168.170.59]) by moroha.quovadx.com (8.13.6/8.13.6) with ESMTP id l7318TBL017488 for ; Fri, 3 Aug 2007 01:08:29 GMT Received: from [10.70.3.113] ([10.70.3.113]) by qxvcexch01.ad.quovadx.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 2 Aug 2007 19:08:22 -0600 Message-ID: <46B28029.1080602@roguewave.com> Date: Thu, 02 Aug 2007 19:08:57 -0600 From: Martin Sebor Organization: Rogue Wave Software User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070221 SeaMonkey/1.1.1 MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: FW: RW libstd is sensitive to link order References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 03 Aug 2007 01:08:22.0054 (UTC) FILETIME=[C91A4460:01C7D56A] X-Virus-Checked: Checked by ClamAV on apache.org Ravi Inampudi wrote: > > A customer discovered a problem with std::numeric_limits in RW > libstd. Placing RW libstd on linkline *before* libFoo results in the > program printing "0" instead of "inf". The problem doesn't happen with > native gcc STL. [...] > But the customer never links their shared libs(i.e libFoo in this > example) with RW libstd. They only link binaries with RW libstd! But it > makes RW libstd sensitive to link order. And they think the problem is > in limits.cpp file: > >> >> static union { >> char _C_bits [sizeof (double)]; >> double _C_inf; >> } __rw_dbl_inf_bits = { _RWSTD_DBL_INF_BITS }; >> >> _RWSTD_EXPORT extern const double __rw_dbl_infinity = >> __rw_dbl_inf_bits._C_inf; >> >> __rw_dbl_infinity ends up in the uninitialized data section of >> libstd_gcc32.so >> >> nm -C libstd_gcc32.so| grep __rw_dbl_infinity >> 000937f8 B __rw::__rw_dbl_infinity >> > > If the symbol was initialized in data section, the link order wouldn't > matter. That's correct. Because the initializer of __rw_dbl_infinity is not a constant expresssion [expr.const] the symbol is initialized dynamically (at runtime) rather than statically (i.e., at load time). It seems that the compiler should be able to initialize it statically anyway, even if it's not required to. Regardless, we should avoid making the assumption that it will and change the initialization of the extern constants to use constant expressions instead. Can you please open an issue for this? Martin