Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 73959 invoked from network); 31 Jul 2006 22:30:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 31 Jul 2006 22:30:45 -0000 Received: (qmail 21419 invoked by uid 500); 31 Jul 2006 22:30:45 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 21367 invoked by uid 500); 31 Jul 2006 22:30:45 -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 21356 invoked by uid 99); 31 Jul 2006 22:30:45 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 31 Jul 2006 15:30:45 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 31 Jul 2006 15:30:44 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 54157410009 for ; Mon, 31 Jul 2006 22:28:14 +0000 (GMT) Message-ID: <7734500.1154384894326.JavaMail.jira@brutus> Date: Mon, 31 Jul 2006 15:28:14 -0700 (PDT) From: "Colin Lee (JIRA)" To: stdcxx-dev@incubator.apache.org Subject: [jira] Commented: (STDCXX-264) LIMITS.cpp WCHAR test causes infinite loop with IPA, nonstandard code In-Reply-To: <11523377.1154377573849.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 X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/STDCXX-264?page=comments#action_12424681 ] Colin Lee commented on STDCXX-264: ---------------------------------- Thanks, you have a very fast response rate! I'll look at it soon. > LIMITS.cpp WCHAR test causes infinite loop with IPA, nonstandard code > --------------------------------------------------------------------- > > Key: STDCXX-264 > URL: http://issues.apache.org/jira/browse/STDCXX-264 > Project: C++ Standard Library > Issue Type: Bug > Components: Configuration > Affects Versions: 4.1.3 > Environment: > uname -a && CC -V > UNICOS/mp sn702 3.0.62 07230830 crayx1 > Cray C++ : Version 5.6.0.0.57 Mon Jul 31, 2006 14:38:56 > Reporter: Colin Lee > Assigned To: Martin Sebor > Priority: Minor > Fix For: 4.2 > > > With any compiler that uses interprocedural analysis including leaf node inlining, this WCHAR test in etc/config/src/LIMITS.cpp invokes undefined behavior from signed integer overflow and can result in an infinite loop. Our compiler inlines the greater() function and invokes undefined behavior, so the loop never exits. One workaround is to disable optimization and run the code by hand, but since this code is hidden within the build process, a portable solution is needed. Here's a code snippet: > template > T greater (T lhs, T rhs) > { > // prevents overzealous gcc optimizer from invoking > // undefined behavior on signed integer over/underflow > return lhs > rhs; > } > template > T compute_limits (T, const char *pfx, const char *sfx, const char *type) > { > T max = T (1); > T one = T (1); > for (; T (max * 2) > max; max *= 2); > for (T n = max / 4; n; ) { > if (T (max + n) < max) { > if (n > 2) > n /= 2; > else if (greater (T (max + one), max)) > n = 1; > else > break; > } > else > max += n; > } > return max; > } > int main(void) { > compute_limits ((wchar_t)0, "WCHAR_T", suffix, "wchar_t"); > return 0; > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira