blob: 929c117fce6994a2fde198bdf2f9c97699881a10 [file] [log] [blame]
Maxwell Henderson80bec322024-01-09 15:48:44 -08001From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Tyler Veness <calcmogul@gmail.com>
3Date: Fri, 10 Nov 2023 14:17:53 -0800
4Subject: [PATCH 12/12] Suppress stringop-overflow warning false positives
5
6---
7 src/google/protobuf/io/coded_stream.h | 7 +++++++
8 src/google/protobuf/unknown_field_set.cc | 7 +++++++
9 2 files changed, 14 insertions(+)
10
11diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
12index 6c0dd4ab4099d1d748957af8bfc5f8c59c2aa3d6..a102cec8ea0b56926f63cf9ece205c634cb6d528 100644
13--- a/src/google/protobuf/io/coded_stream.h
14+++ b/src/google/protobuf/io/coded_stream.h
15@@ -681,7 +681,14 @@ class PROTOBUF_EXPORT EpsCopyOutputStream {
16 if (PROTOBUF_PREDICT_FALSE(end_ - ptr < static_cast<int>(size))) {
17 return WriteRawFallback(data, size, ptr);
18 }
19+#if __GNUC__ >= 13
20+#pragma GCC diagnostic push
21+#pragma GCC diagnostic ignored "-Wstringop-overflow="
22+#endif // __GNUC__ >= 13
23 std::memcpy(ptr, data, size);
24+#if __GNUC__ >= 13
25+#pragma GCC diagnostic pop
26+#endif // __GNUC__ >= 13
27 return ptr + size;
28 }
29 // Writes the buffer specified by data, size to the stream. Possibly by
30diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc
31index 74c358e9a22c5475bfaef6c5ac63b05fc61b7074..c0587350b309839f3b8b99506d0417a9fd91b06d 100644
32--- a/src/google/protobuf/unknown_field_set.cc
33+++ b/src/google/protobuf/unknown_field_set.cc
34@@ -96,9 +96,16 @@ void UnknownFieldSet::MergeFromAndDestroy(UnknownFieldSet* other) {
35 if (fields_.empty()) {
36 fields_ = std::move(other->fields_);
37 } else {
38+#if __GNUC__ >= 13
39+#pragma GCC diagnostic push
40+#pragma GCC diagnostic ignored "-Wstringop-overflow="
41+#endif // __GNUC__ >= 13
42 fields_.insert(fields_.end(),
43 std::make_move_iterator(other->fields_.begin()),
44 std::make_move_iterator(other->fields_.end()));
45+#if __GNUC__ >= 13
46+#pragma GCC diagnostic pop
47+#endif // __GNUC__ >= 13
48 }
49 other->fields_.clear();
50 }