Fix GCC 12.1 warning false positives (#4246)

This commit is contained in:
Tyler Veness
2022-05-18 12:22:10 -07:00
committed by GitHub
parent 5876b40f08
commit 6a4752dcdc
15 changed files with 144 additions and 36 deletions

View File

@@ -87,9 +87,21 @@ template <typename T, HAL_Value (*MakeValue)(T), const char* (*GetName)(),
T (*GetDefault)() = nullptr>
class SimDataValue final : public impl::SimDataValueBase<T, MakeValue> {
public:
// FIXME: GCC 12.1 gives the false positive "the address of <GetDefault> will
// never be NULL" because it doesn't realize the default template parameter can
// make GetDefault nullptr. In C++20, replace "T (*GetDefault)() = nullptr" with
// "T (*GetDefault)() = [] { return T(); }" and unconditionally call
// GetDefault() to fix the warning.
#if __GNUC__ >= 12
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Waddress"
#endif // __GNUC__ >= 12
SimDataValue()
: impl::SimDataValueBase<T, MakeValue>(
GetDefault != nullptr ? GetDefault() : T()) {}
#if __GNUC__ >= 12
#pragma GCC diagnostic pop
#endif // __GNUC__ >= 12
explicit SimDataValue(T value)
: impl::SimDataValueBase<T, MakeValue>(value) {}

View File

@@ -1,15 +0,0 @@
diff --git a/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h b/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h
index 74f74cc42..5fe86fa0d 100644
--- a/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h
+++ b/wpimath/src/main/native/eigeninclude/Eigen/src/Core/util/DisableStupidWarnings.h
@@ -61,6 +61,10 @@
// See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325
#pragma GCC diagnostic ignored "-Wattributes"
#endif
+ #if __GNUC__==11
+ // This warning is a false positive
+ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+ #endif
#endif
#if defined __NVCC__

View File

@@ -0,0 +1,31 @@
From 6257b7a01bb498bd895e27146528f9362152e447 Mon Sep 17 00:00:00 2001
From: Tyler Veness <calcmogul@gmail.com>
Date: Wed, 18 May 2022 09:14:24 -0700
Subject: [PATCH] Disable warnings
---
Eigen/src/Core/util/DisableStupidWarnings.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Eigen/src/Core/util/DisableStupidWarnings.h b/Eigen/src/Core/util/DisableStupidWarnings.h
index fe0cfec0b..f489c3add 100755
--- a/Eigen/src/Core/util/DisableStupidWarnings.h
+++ b/Eigen/src/Core/util/DisableStupidWarnings.h
@@ -71,6 +71,14 @@
// See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325
#pragma GCC diagnostic ignored "-Wattributes"
#endif
+ #if __GNUC__==11
+ // This warning is a false positive
+ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+ #endif
+ #if __GNUC__==12
+ // This warning is a false positive
+ #pragma GCC diagnostic ignored "-Warray-bounds"
+ #endif
#endif
#if defined __NVCC__
--
2.36.1

View File

@@ -1,7 +1,7 @@
From bb42f9b81e12e52b5401c4afa879242b46615a4e Mon Sep 17 00:00:00 2001
From d4f625eae1faf75f3a195f7a918d6d09c626243e Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:01:25 -0400
Subject: [PATCH 1/6] Fix missing casts
Subject: [PATCH 1/7] Fix missing casts
---
include/uv/unix.h | 2 +-
@@ -1414,5 +1414,5 @@ index 7ca83213..d1cd19ba 100644
if (*utf16 == NULL)
return UV_ENOMEM;
--
2.20.1.windows.1
2.36.1

View File

@@ -1,7 +1,7 @@
From c2390ddd8fa648c87adf279ed5b3489a42c07e67 Mon Sep 17 00:00:00 2001
From 6a2f0c13071618ae8cbf84bff2e659b862e57ecd Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:09:43 -0400
Subject: [PATCH 2/6] Fix warnings
Subject: [PATCH 2/7] Fix warnings
---
include/uv/win.h | 5 +++++
@@ -247,5 +247,5 @@ index a5d58bf7..deec66fe 100644
#include <io.h>
#include <string.h>
--
2.20.1.windows.1
2.36.1

View File

@@ -1,7 +1,7 @@
From 80055296378f0a8ad0eec823fd2d0209a447fd22 Mon Sep 17 00:00:00 2001
From b2ce6f41afa612eb31a8c8ac3e5f23783fb81d5f Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:19:14 -0400
Subject: [PATCH 3/6] Preprocessor cleanup
Subject: [PATCH 3/7] Preprocessor cleanup
---
include/uv.h | 18 +-----------------
@@ -198,5 +198,5 @@ index 5820ba9c..918acaf5 100644
/* Whether there are any non-IFS LSPs stacked on TCP */
int uv_tcp_non_ifs_lsp_ipv4;
--
2.20.1.windows.1
2.36.1

View File

@@ -1,7 +1,7 @@
From 5649a07d496fecd1812265b86b329186af78c3fc Mon Sep 17 00:00:00 2001
From ea00b73593e7146c01df4320e3e2e345665fd1c3 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:24:47 -0400
Subject: [PATCH 4/6] Cleanup problematic language
Subject: [PATCH 4/7] Cleanup problematic language
---
src/unix/tty.c | 21 +++++++++++----------
@@ -60,5 +60,5 @@ index 74d3d75d..5f681406 100644
else
r = -1;
--
2.20.1.windows.1
2.36.1

View File

@@ -1,7 +1,7 @@
From bb5cdf6360308dce34546f55d02f8073b88dd748 Mon Sep 17 00:00:00 2001
From a033a549b944b5ea9d9b2d8c7e73bbf8165232ec Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:26:03 -0400
Subject: [PATCH 5/6] Use roborio time
Subject: [PATCH 5/7] Use roborio time
---
src/unix/linux-core.c | 8 ++++++++
@@ -41,5 +41,5 @@ index a66bb535..8a267823 100644
--
2.20.1.windows.1
2.36.1

View File

@@ -1,7 +1,7 @@
From a9ec38882aa39841109dd001b1122c2ff60454e6 Mon Sep 17 00:00:00 2001
From 88a584f62e18a04a70336027062141739e1591bf Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Tue, 26 Apr 2022 15:28:52 -0400
Subject: [PATCH 6/6] Style / comments cleanup
Subject: [PATCH 6/7] Style / comments cleanup
---
src/fs-poll.c | 1 +
@@ -101,5 +101,5 @@ index 918acaf5..668e3b64 100644
/* Whether there are any non-IFS LSPs stacked on TCP */
--
2.20.1.windows.1
2.36.1

View File

@@ -0,0 +1,55 @@
From aca70965b0a80000cb8281d097c78a3e3e0feb16 Mon Sep 17 00:00:00 2001
From: Tyler Veness <calcmogul@gmail.com>
Date: Tue, 17 May 2022 21:36:57 -0700
Subject: [PATCH 7/7] Squelch GCC 12.1 warnings
---
src/unix/stream.c | 9 +++++++++
src/uv-common.c | 9 +++++++++
2 files changed, 18 insertions(+)
diff --git a/src/unix/stream.c b/src/unix/stream.c
index f3a8e66d..8aeca159 100644
--- a/src/unix/stream.c
+++ b/src/unix/stream.c
@@ -932,7 +932,16 @@ static void uv__write_callbacks(uv_stream_t* stream) {
if (QUEUE_EMPTY(&stream->write_completed_queue))
return;
+// FIXME: GCC 12.1 gives a possibly real warning, but we don't know how to fix
+// it
+#if __GNUC__ >= 12
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdangling-pointer="
+#endif // __GNUC__ >= 12
QUEUE_MOVE(&stream->write_completed_queue, &pq);
+#if __GNUC__ >= 12
+#pragma GCC diagnostic pop
+#endif // __GNUC__ >= 12
while (!QUEUE_EMPTY(&pq)) {
/* Pop a req off write_completed_queue. */
diff --git a/src/uv-common.c b/src/uv-common.c
index 3c65476a..fd56b013 100644
--- a/src/uv-common.c
+++ b/src/uv-common.c
@@ -444,7 +444,16 @@ void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) {
QUEUE* q;
uv_handle_t* h;
+// FIXME: GCC 12.1 gives a possibly real warning, but we don't know how to fix
+// it
+#if __GNUC__ >= 12
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdangling-pointer="
+#endif // __GNUC__ >= 12
QUEUE_MOVE(&loop->handle_queue, &queue);
+#if __GNUC__ >= 12
+#pragma GCC diagnostic pop
+#endif // __GNUC__ >= 12
while (!QUEUE_EMPTY(&queue)) {
q = QUEUE_HEAD(&queue);
h = QUEUE_DATA(q, uv_handle_t, handle_queue);
--
2.36.1

View File

@@ -4,7 +4,7 @@ import os
import re
import shutil
from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, walk_cwd_and_copy_if, apply_patches
from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, walk_cwd_and_copy_if, am_patches
def eigen_inclusions(dp, f):
@@ -91,6 +91,10 @@ def main():
"3.4.0")
wpimath = os.path.join(root, "wpimath")
# Apply patches to original git repo
prefix = os.path.join(root, "upstream_utils/eigen_patches")
am_patches(repo, [os.path.join(prefix, "0001-Disable-warnings.patch")])
# Delete old install
for d in [
"src/main/native/eigeninclude/Eigen",
@@ -114,8 +118,6 @@ def main():
comment_out_invalid_includes(
f, [os.path.join(wpimath, "src/main/native/eigeninclude")])
apply_patches(root, ["upstream_utils/eigen-maybe-uninitialized.patch"])
if __name__ == "__main__":
main()

View File

@@ -20,6 +20,7 @@ def main():
os.path.join(root, "upstream_utils/libuv_patches/0004-Cleanup-problematic-language.patch"),
os.path.join(root, "upstream_utils/libuv_patches/0005-Use-roborio-time.patch"),
os.path.join(root, "upstream_utils/libuv_patches/0006-Style-comments-cleanup.patch"),
os.path.join(root, "upstream_utils/libuv_patches/0007-Squelch-GCC-12.1-warnings.patch"),
])
# yapf: enable

View File

@@ -75,6 +75,10 @@
// This warning is a false positive
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
#if __GNUC__==12
// This warning is a false positive
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
#endif
#if defined __NVCC__

View File

@@ -932,7 +932,16 @@ static void uv__write_callbacks(uv_stream_t* stream) {
if (QUEUE_EMPTY(&stream->write_completed_queue))
return;
// FIXME: GCC 12.1 gives a possibly real warning, but we don't know how to fix
// it
#if __GNUC__ >= 12
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-pointer="
#endif // __GNUC__ >= 12
QUEUE_MOVE(&stream->write_completed_queue, &pq);
#if __GNUC__ >= 12
#pragma GCC diagnostic pop
#endif // __GNUC__ >= 12
while (!QUEUE_EMPTY(&pq)) {
/* Pop a req off write_completed_queue. */

View File

@@ -444,7 +444,16 @@ void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) {
QUEUE* q;
uv_handle_t* h;
// FIXME: GCC 12.1 gives a possibly real warning, but we don't know how to fix
// it
#if __GNUC__ >= 12
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-pointer="
#endif // __GNUC__ >= 12
QUEUE_MOVE(&loop->handle_queue, &queue);
#if __GNUC__ >= 12
#pragma GCC diagnostic pop
#endif // __GNUC__ >= 12
while (!QUEUE_EMPTY(&queue)) {
q = QUEUE_HEAD(&queue);
h = QUEUE_DATA(q, uv_handle_t, handle_queue);