summaryrefslogtreecommitdiff
path: root/debian/patches
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2021-01-31 15:02:36 -0500
committerGravatar Benjamin Barenblat <bbaren@google.com>2021-01-31 15:04:49 -0500
commit1f93c7bc4f508dbc9d3eb2848b8d2b4cd572eb38 (patch)
treef01199d13ac79fea90f734d42742b39e6e257efc /debian/patches
parent9229f2a0b73adb577b85e30b3060862c1c583d1a (diff)
Work around GCC bug narrowing NaNs
Work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98251 by preventing NaN narrowing in unit tests.
Diffstat (limited to 'debian/patches')
-rw-r--r--debian/patches/nan-narrowing.diff25
-rw-r--r--debian/patches/series1
2 files changed, 26 insertions, 0 deletions
diff --git a/debian/patches/nan-narrowing.diff b/debian/patches/nan-narrowing.diff
new file mode 100644
index 00000000..c7ec9325
--- /dev/null
+++ b/debian/patches/nan-narrowing.diff
@@ -0,0 +1,25 @@
+From: Benjamin Barenblat <bbaren@google.com>
+Subject: Avoid libgcc -NaN narrowing bug
+Forwarded: yes
+Applied-Upstream: https://github.com/abseil/abseil-cpp/commit/1bae23e32ba1f1af7c7d1488a69a351ec96dc98d
+
+When testing -NaN parsing, avoid narrowing -NaN from double to float. This
+avoids a bug in libgcc (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98251).
+
+The author works at Google. Upstream applied this patch as Piper revision
+347654751 and exported it to GitHub; the Applied-Upstream URL above points to
+the exported commit.
+
+--- a/absl/strings/charconv_test.cc
++++ b/absl/strings/charconv_test.cc
+@@ -653,7 +653,9 @@ TEST(FromChars, NaNFloats) {
+ negative_from_chars_float);
+ EXPECT_TRUE(std::signbit(negative_from_chars_float));
+ EXPECT_FALSE(Identical(negative_from_chars_float, from_chars_float));
+- from_chars_float = std::copysign(from_chars_float, -1.0);
++ // Use the (float, float) overload of std::copysign to prevent narrowing;
++ // see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98251.
++ from_chars_float = std::copysign(from_chars_float, -1.0f);
+ EXPECT_TRUE(Identical(negative_from_chars_float, from_chars_float));
+ }
+ }
diff --git a/debian/patches/series b/debian/patches/series
index cf05a43f..9c73d904 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@ fix-hppa.diff
std-hash.diff
latomic.diff
cpu-frequency.diff
+nan-narrowing.diff