Work around cray++ compiler issue

It's still not clear as to what exactly makes it emit this error when compiling
string_to_integer:

CC-3059 crayc++: INTERNAL __C_FILE_SCOPE_DATA__, File = <pugixml>/src/pugixml.cpp, Line = 4524, Column = 4
  Expected no overflow in routine.

But a viable workaround for now is to exploit the knowledge that it uses
two-complement arithmetics and invert the sign manually.

Fixes #125.
This commit is contained in:
Arseny Kapoulkine 2016-12-01 20:49:46 -08:00
parent e3524c90de
commit 05edb250ee

View File

@ -4521,7 +4521,14 @@ PUGI__NS_BEGIN
}
if (negative)
{
// Workaround for crayc++ CC-3059: Expected no overflow in routine.
#ifdef _CRAYC
return (overflow || result > minneg) ? ~minneg + 1 : ~result + 1;
#else
return (overflow || result > minneg) ? 0 - minneg : 0 - result;
#endif
}
else
return (overflow || result > maxpos) ? maxpos : result;
}