[PATCH] Support/APFloat, fix assert on convertFromString(toString(infty))
Johan Engelen
jbc.engelen at swissonline.ch
Mon Mar 16 15:54:45 PDT 2015
Hello,
Here is a patch for /lib/Support/APFloat.cpp that fixes an assert
when the output of APFloat::toString() is fed back into
APFloat::convertFromString().
For infinity, toString() outputs a string with upper case "Inf", whereas
convertFromString() only accepts lowercase "inf".
The patch adds "Inf" and "-Inf" to the accepted strings in
convertFromString(), and modifies the output from toString() to "Inf"
instead of "+Inf" for positive infinity.
Thanks,
Johan
-------------- next part --------------
Index: lib/Support/APFloat.cpp
===================================================================
--- lib/Support/APFloat.cpp (revision 232407)
+++ lib/Support/APFloat.cpp (working copy)
@@ -2615,12 +2615,12 @@
bool
APFloat::convertFromStringSpecials(StringRef str) {
- if (str.equals("inf") || str.equals("INFINITY")) {
+ if (str.equals("inf") || str.equals("Inf") || str.equals("INFINITY")) {
makeInf(false);
return true;
}
- if (str.equals("-inf") || str.equals("-INFINITY")) {
+ if (str.equals("-inf") || str.equals("-Inf") || str.equals("-INFINITY")) {
makeInf(true);
return true;
}
@@ -3549,7 +3549,7 @@
if (isNegative())
return append(Str, "-Inf");
else
- return append(Str, "+Inf");
+ return append(Str, "Inf");
case fcNaN: return append(Str, "NaN");
More information about the llvm-commits
mailing list