[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 08/10: [refer]: Fix Savannah #66078 (array comp thinko).
From: |
G. Branden Robinson |
Subject: |
[groff] 08/10: [refer]: Fix Savannah #66078 (array comp thinko). |
Date: |
Thu, 17 Oct 2024 20:39:43 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 6483156146591c986948149ee55beacfd937bb12
Author: Lukas Javorsky <ljavorsk@redhat.com>
AuthorDate: Mon Aug 12 14:38:00 2024 +0200
[refer]: Fix Savannah #66078 (array comp thinko).
* src/preproc/refer/ref.cpp (same_reference): Fix array comparison
warning by comparing elements individually.
Fixes <https://savannah.gnu.org/bugs/?66078>.
[One such warning is "comparison between two arrays is deprecated in
C++20". While groff uses C++98, if the compiler were to expand the
array reference into a loop on its own, then it was blowing up an O(n)
procedure to O(n^2). And if it didn't do that, but translated the
expressions effectively to `r1.field_index[0] != r2.field_index[0]`,
comparing them `i` times, then it's an outright logic error. Problem
dates back to groff 1.02 (June 1991), and perhaps earlier. --GBR]
---
ChangeLog | 7 +++++++
src/preproc/refer/ref.cpp | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index bd47d77ca..974c732e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-08-14 Lukas Javorsky <ljavorsk@redhat.com>
+
+ * src/preproc/refer/ref.cpp (same_reference): Fix array
+ comparison warning by comparing elements individually.
+
+ Fixes <https://savannah.gnu.org/bugs/?66078>.
+
2024-08-14 Lukas Javorsky <ljavorsk@redhat.com>
* src/preproc/pic/object.cpp (object_spec::position_rectangle)
diff --git a/src/preproc/refer/ref.cpp b/src/preproc/refer/ref.cpp
index 5f6d5c63a..65b7edaf3 100644
--- a/src/preproc/refer/ref.cpp
+++ b/src/preproc/refer/ref.cpp
@@ -536,7 +536,7 @@ int same_reference(const reference &r1, const reference &r2)
return 0;
int i = 0;
for (i = 0; i < 256; i++)
- if (r1.field_index != r2.field_index)
+ if (r1.field_index[i] != r2.field_index[i])
return 0;
for (i = 0; i < r1.nfields; i++)
if (r1.field[i] != r2.field[i])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 08/10: [refer]: Fix Savannah #66078 (array comp thinko).,
G. Branden Robinson <=