Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 96381 invoked from network); 9 Aug 2007 01:11:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Aug 2007 01:11:25 -0000 Received: (qmail 19275 invoked by uid 500); 9 Aug 2007 01:11:24 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 19216 invoked by uid 500); 9 Aug 2007 01:11:24 -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 19205 invoked by uid 99); 9 Aug 2007 01:11:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Aug 2007 18:11:24 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2007 01:11:20 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 1851071417D for ; Wed, 8 Aug 2007 18:11:00 -0700 (PDT) Message-ID: <15957597.1186621860096.JavaMail.jira@brutus> Date: Wed, 8 Aug 2007 18:11:00 -0700 (PDT) From: "Martin Sebor (JIRA)" To: stdcxx-dev@incubator.apache.org Subject: [jira] Updated: (STDCXX-509) std::numeric_limits::infinity() depends on dynamic initialization In-Reply-To: <31762731.1186177012819.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-509?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Martin Sebor updated STDCXX-509: -------------------------------- Component/s: (was: Build) 18. Language Support Affects Version/s: 4.1.3 Fix Version/s: (was: 4.1.2) 4.2 Issue Type: Bug (was: Improvement) Summary: std::numeric_limits::infinity() depends on dynamic initialization (was: RW libstd is sensitive to link order) Changing Issue Type to Bug. It's is more than an Improvement: the library should not rely on dynamic initialization where it may be detectable in user code. Changing component to Language Support (it affects std::numeric_limits), adding 4.1.3 to Affected Versions, and scheduling the fix for 4.2. > std::numeric_limits::infinity() depends on dynamic initialization > ------------------------------------------------------------------------- > > Key: STDCXX-509 > URL: https://issues.apache.org/jira/browse/STDCXX-509 > Project: C++ Standard Library > Issue Type: Bug > Components: 18. Language Support > Affects Versions: 4.1.3, 4.1.2 > Environment: gcc3.2, linux AS3.0 > Reporter: Ravi K Inampudi > Assignee: Martin Sebor > Fix For: 4.2 > > Attachments: limits_bits.cpp.patch > > > 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. > We reproduced the problem with the latest version of standard library downloaded from Apache. From our understanding, when creating the libFoo.so and using the native standard library is creating an implicit dependency on the libsupc++ (compiler dependent). This implicit dependency is initializing the static variable when libFoo.so is loaded. If we use RW libstd instread of libstdc++(native gcc stl), the program will print "0" instead of "inf". > # make shared lib > gcc -I/amd/homes/dean/temp/stdlib-cxx/stdcxx-4.1.3/include/ansi -pthread -D_RWSTD_USE_CONFIG -I/nfs/homes/dean/temp/stdlib-cxx/12d/include -I/amd/homes/dean/temp/stdlib-cxx/stdcxx-4.1.3/include -I/amd/homes/dean/temp/stdlib-cxx/stdcxx-4.1.3/examples/include -pedantic -nostdinc++ -O2 -Wall -W -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align -fPIC -shared -o libFooRW-link.so foo.C > # make binary. > gcc -pthread -o mainRW main.C -L/nfs/homes/dean/temp/stdlib-cxx/12d/lib -lstd12d -lsupc++ -lm -lFooRW > However, using the RW standard library, if such dependency is created explicitly then it prints "inf". For example, the following set of commands fixes the problem: > # make shared lib > gcc -I/amd/homes/dean/temp/stdlib-cxx/stdcxx-4.1.3/include/ansi -pthread -D_RWSTD_USE_CONFIG -I/nfs/homes/dean/temp/stdlib-cxx/12d/include -I/amd/homes/dean/temp/stdlib-cxx/stdcxx-4.1.3/include -I/amd/homes/dean/temp/stdlib-cxx/stdcxx-4.1.3/examples/include -pedantic -nostdinc++ -O2 -Wall -W -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align -fPIC -shared -o libFooRW-link.so foo.C -lstd12d > # make binary. > gcc -pthread -o mainRW main.C -L/nfs/homes/dean/temp/stdlib-cxx/12d/lib -lstd12d -lsupc++ -lm -lFooRW > 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. > Environment: RWSP6, gcc3.2, linux AS3.0 > Martin Sebor's Comments: > 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. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.