[ http://issues.apache.org/jira/browse/STDCXX-264?page=all ]
Martin Sebor resolved STDCXX-264.
---------------------------------
Fix Version/s: 4.2
Resolution: Fixed
The referenced patch should fix it. Colin -- please let us know if the problem
persists.
> 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 <class T>
> T greater (T lhs, T rhs)
> {
> // prevents overzealous gcc optimizer from invoking
> // undefined behavior on signed integer over/underflow
> return lhs > rhs;
> }
> template <class T>
> 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