diff --git a/upstream_utils/protobuf_patches/0001-Fix-sign-compare-warnings.patch b/upstream_utils/protobuf_patches/0001-Fix-sign-compare-warnings.patch index e916c0fa2e..d3ac55c09d 100644 --- a/upstream_utils/protobuf_patches/0001-Fix-sign-compare-warnings.patch +++ b/upstream_utils/protobuf_patches/0001-Fix-sign-compare-warnings.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 10 Jun 2023 14:13:07 -0700 -Subject: [PATCH 01/11] Fix sign-compare warnings +Subject: [PATCH 01/12] Fix sign-compare warnings --- src/google/protobuf/compiler/importer.cc | 2 +- diff --git a/upstream_utils/protobuf_patches/0002-Remove-redundant-move.patch b/upstream_utils/protobuf_patches/0002-Remove-redundant-move.patch index 09ab3c5c0a..6916c98bd2 100644 --- a/upstream_utils/protobuf_patches/0002-Remove-redundant-move.patch +++ b/upstream_utils/protobuf_patches/0002-Remove-redundant-move.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 10 Jun 2023 14:41:39 -0700 -Subject: [PATCH 02/11] Remove redundant move +Subject: [PATCH 02/12] Remove redundant move --- src/google/protobuf/extension_set.h | 2 +- diff --git a/upstream_utils/protobuf_patches/0003-Fix-maybe-uninitialized-warnings.patch b/upstream_utils/protobuf_patches/0003-Fix-maybe-uninitialized-warnings.patch index 40ee920fd4..6888dd25ee 100644 --- a/upstream_utils/protobuf_patches/0003-Fix-maybe-uninitialized-warnings.patch +++ b/upstream_utils/protobuf_patches/0003-Fix-maybe-uninitialized-warnings.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 10 Jun 2023 15:00:20 -0700 -Subject: [PATCH 03/11] Fix maybe-uninitialized warnings +Subject: [PATCH 03/12] Fix maybe-uninitialized warnings --- src/google/protobuf/arena.cc | 6 +++--- diff --git a/upstream_utils/protobuf_patches/0004-Fix-coded_stream-WriteRaw.patch b/upstream_utils/protobuf_patches/0004-Fix-coded_stream-WriteRaw.patch index 90fe162c29..dc17497b7b 100644 --- a/upstream_utils/protobuf_patches/0004-Fix-coded_stream-WriteRaw.patch +++ b/upstream_utils/protobuf_patches/0004-Fix-coded_stream-WriteRaw.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 10 Jun 2023 15:03:38 -0700 -Subject: [PATCH 04/11] Fix coded_stream WriteRaw +Subject: [PATCH 04/12] Fix coded_stream WriteRaw --- src/google/protobuf/implicit_weak_message.h | 2 +- diff --git a/upstream_utils/protobuf_patches/0005-Suppress-enum-enum-conversion-warning.patch b/upstream_utils/protobuf_patches/0005-Suppress-enum-enum-conversion-warning.patch index 85d12a0300..2919644e3e 100644 --- a/upstream_utils/protobuf_patches/0005-Suppress-enum-enum-conversion-warning.patch +++ b/upstream_utils/protobuf_patches/0005-Suppress-enum-enum-conversion-warning.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 10 Jun 2023 15:13:45 -0700 -Subject: [PATCH 05/11] Suppress enum-enum conversion warning +Subject: [PATCH 05/12] Suppress enum-enum conversion warning --- src/google/protobuf/generated_message_tctable_impl.h | 9 +++++++++ diff --git a/upstream_utils/protobuf_patches/0006-Fix-noreturn-function-returning.patch b/upstream_utils/protobuf_patches/0006-Fix-noreturn-function-returning.patch index d255d80222..abaa0a20b9 100644 --- a/upstream_utils/protobuf_patches/0006-Fix-noreturn-function-returning.patch +++ b/upstream_utils/protobuf_patches/0006-Fix-noreturn-function-returning.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 10 Jun 2023 15:16:46 -0700 -Subject: [PATCH 06/11] Fix noreturn function returning +Subject: [PATCH 06/12] Fix noreturn function returning --- src/google/protobuf/generated_message_tctable_impl.h | 3 +++ diff --git a/upstream_utils/protobuf_patches/0007-Work-around-GCC-12-restrict-warning-compiler-bug.patch b/upstream_utils/protobuf_patches/0007-Work-around-GCC-12-restrict-warning-compiler-bug.patch index aa67e21191..543896c2bc 100644 --- a/upstream_utils/protobuf_patches/0007-Work-around-GCC-12-restrict-warning-compiler-bug.patch +++ b/upstream_utils/protobuf_patches/0007-Work-around-GCC-12-restrict-warning-compiler-bug.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 10 Jun 2023 15:59:45 -0700 -Subject: [PATCH 07/11] Work around GCC 12 restrict warning compiler bug +Subject: [PATCH 07/12] Work around GCC 12 restrict warning compiler bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329 --- diff --git a/upstream_utils/protobuf_patches/0008-Disable-MSVC-switch-warning.patch b/upstream_utils/protobuf_patches/0008-Disable-MSVC-switch-warning.patch index b0c485b3a3..92654f0ff6 100644 --- a/upstream_utils/protobuf_patches/0008-Disable-MSVC-switch-warning.patch +++ b/upstream_utils/protobuf_patches/0008-Disable-MSVC-switch-warning.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 13 Jun 2023 23:56:15 -0700 -Subject: [PATCH 08/11] Disable MSVC switch warning +Subject: [PATCH 08/12] Disable MSVC switch warning --- src/google/protobuf/generated_message_reflection.cc | 4 ++++ diff --git a/upstream_utils/protobuf_patches/0009-Disable-unused-function-warning.patch b/upstream_utils/protobuf_patches/0009-Disable-unused-function-warning.patch index b3aa64e038..9a8864951c 100644 --- a/upstream_utils/protobuf_patches/0009-Disable-unused-function-warning.patch +++ b/upstream_utils/protobuf_patches/0009-Disable-unused-function-warning.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 13 Jun 2023 23:58:50 -0700 -Subject: [PATCH 09/11] Disable unused function warning +Subject: [PATCH 09/12] Disable unused function warning --- src/google/protobuf/generated_message_tctable_lite.cc | 4 ++++ diff --git a/upstream_utils/protobuf_patches/0010-Disable-pedantic-warning.patch b/upstream_utils/protobuf_patches/0010-Disable-pedantic-warning.patch index 1555d19029..dd1860e79d 100644 --- a/upstream_utils/protobuf_patches/0010-Disable-pedantic-warning.patch +++ b/upstream_utils/protobuf_patches/0010-Disable-pedantic-warning.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 14 Jun 2023 00:02:26 -0700 -Subject: [PATCH 10/11] Disable pedantic warning +Subject: [PATCH 10/12] Disable pedantic warning --- src/google/protobuf/descriptor.h | 8 ++++++++ diff --git a/upstream_utils/protobuf_patches/0011-Avoid-use-of-sprintf.patch b/upstream_utils/protobuf_patches/0011-Avoid-use-of-sprintf.patch index 27e81afd9f..a0dfad8655 100644 --- a/upstream_utils/protobuf_patches/0011-Avoid-use-of-sprintf.patch +++ b/upstream_utils/protobuf_patches/0011-Avoid-use-of-sprintf.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Mon, 9 Oct 2023 19:28:08 -0700 -Subject: [PATCH 11/11] Avoid use of sprintf +Subject: [PATCH 11/12] Avoid use of sprintf --- src/google/protobuf/stubs/strutil.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc -index 3462e91ff273dc071628f06b91698a0f166514fc..e063d0d3039c87d55a6df0dbfe50f365184fe292 100644 +index 3462e91ff273dc071628f06b91698a0f166514fc..58e03d0c4aa7c1b0337b5f650283f00117c12baa 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -503,10 +503,18 @@ int CEscapeInternal(const char* src, int src_len, char* dest, diff --git a/upstream_utils/protobuf_patches/0012-Suppress-stringop-overflow-warning-false-positives.patch b/upstream_utils/protobuf_patches/0012-Suppress-stringop-overflow-warning-false-positives.patch new file mode 100644 index 0000000000..929c117fce --- /dev/null +++ b/upstream_utils/protobuf_patches/0012-Suppress-stringop-overflow-warning-false-positives.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Fri, 10 Nov 2023 14:17:53 -0800 +Subject: [PATCH 12/12] Suppress stringop-overflow warning false positives + +--- + src/google/protobuf/io/coded_stream.h | 7 +++++++ + src/google/protobuf/unknown_field_set.cc | 7 +++++++ + 2 files changed, 14 insertions(+) + +diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h +index 6c0dd4ab4099d1d748957af8bfc5f8c59c2aa3d6..a102cec8ea0b56926f63cf9ece205c634cb6d528 100644 +--- a/src/google/protobuf/io/coded_stream.h ++++ b/src/google/protobuf/io/coded_stream.h +@@ -681,7 +681,14 @@ class PROTOBUF_EXPORT EpsCopyOutputStream { + if (PROTOBUF_PREDICT_FALSE(end_ - ptr < static_cast(size))) { + return WriteRawFallback(data, size, ptr); + } ++#if __GNUC__ >= 13 ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wstringop-overflow=" ++#endif // __GNUC__ >= 13 + std::memcpy(ptr, data, size); ++#if __GNUC__ >= 13 ++#pragma GCC diagnostic pop ++#endif // __GNUC__ >= 13 + return ptr + size; + } + // Writes the buffer specified by data, size to the stream. Possibly by +diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc +index 74c358e9a22c5475bfaef6c5ac63b05fc61b7074..c0587350b309839f3b8b99506d0417a9fd91b06d 100644 +--- a/src/google/protobuf/unknown_field_set.cc ++++ b/src/google/protobuf/unknown_field_set.cc +@@ -96,9 +96,16 @@ void UnknownFieldSet::MergeFromAndDestroy(UnknownFieldSet* other) { + if (fields_.empty()) { + fields_ = std::move(other->fields_); + } else { ++#if __GNUC__ >= 13 ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wstringop-overflow=" ++#endif // __GNUC__ >= 13 + fields_.insert(fields_.end(), + std::make_move_iterator(other->fields_.begin()), + std::make_move_iterator(other->fields_.end())); ++#if __GNUC__ >= 13 ++#pragma GCC diagnostic pop ++#endif // __GNUC__ >= 13 + } + other->fields_.clear(); + } diff --git a/upstream_utils/update_protobuf.py b/upstream_utils/update_protobuf.py index fbecb9c062..1f004cd0c4 100755 --- a/upstream_utils/update_protobuf.py +++ b/upstream_utils/update_protobuf.py @@ -276,6 +276,7 @@ def main(): "0009-Disable-unused-function-warning.patch", "0010-Disable-pedantic-warning.patch", "0011-Avoid-use-of-sprintf.patch", + "0012-Suppress-stringop-overflow-warning-false-positives.patch", ]: git_am(os.path.join(wpilib_root, "upstream_utils/protobuf_patches", f)) diff --git a/wpiutil/src/main/native/thirdparty/protobuf/include/google/protobuf/io/coded_stream.h b/wpiutil/src/main/native/thirdparty/protobuf/include/google/protobuf/io/coded_stream.h index 6c0dd4ab40..a102cec8ea 100644 --- a/wpiutil/src/main/native/thirdparty/protobuf/include/google/protobuf/io/coded_stream.h +++ b/wpiutil/src/main/native/thirdparty/protobuf/include/google/protobuf/io/coded_stream.h @@ -681,7 +681,14 @@ class PROTOBUF_EXPORT EpsCopyOutputStream { if (PROTOBUF_PREDICT_FALSE(end_ - ptr < static_cast(size))) { return WriteRawFallback(data, size, ptr); } +#if __GNUC__ >= 13 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow=" +#endif // __GNUC__ >= 13 std::memcpy(ptr, data, size); +#if __GNUC__ >= 13 +#pragma GCC diagnostic pop +#endif // __GNUC__ >= 13 return ptr + size; } // Writes the buffer specified by data, size to the stream. Possibly by diff --git a/wpiutil/src/main/native/thirdparty/protobuf/src/unknown_field_set.cpp b/wpiutil/src/main/native/thirdparty/protobuf/src/unknown_field_set.cpp index 74c358e9a2..c0587350b3 100644 --- a/wpiutil/src/main/native/thirdparty/protobuf/src/unknown_field_set.cpp +++ b/wpiutil/src/main/native/thirdparty/protobuf/src/unknown_field_set.cpp @@ -96,9 +96,16 @@ void UnknownFieldSet::MergeFromAndDestroy(UnknownFieldSet* other) { if (fields_.empty()) { fields_ = std::move(other->fields_); } else { +#if __GNUC__ >= 13 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow=" +#endif // __GNUC__ >= 13 fields_.insert(fields_.end(), std::make_move_iterator(other->fields_.begin()), std::make_move_iterator(other->fields_.end())); +#if __GNUC__ >= 13 +#pragma GCC diagnostic pop +#endif // __GNUC__ >= 13 } other->fields_.clear(); }