public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] PR middle-end/93437 - bogus -Warray-bounds on protobuf generated code
@ 2020-01-31 17:49 Nathan Sidwell
0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-01-31 17:49 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4dd27b527c503aa50909fe1eb7d308266b1e103a
commit 4dd27b527c503aa50909fe1eb7d308266b1e103a
Author: Martin Sebor <msebor@redhat.com>
Date: Tue Jan 28 14:48:52 2020 -0700
PR middle-end/93437 - bogus -Warray-bounds on protobuf generated code
gcc/testsuite/ChangeLog:
PR middle-end/93437
* g++.dg/warn/Wstringop-overflow-5.C: New test.
Diff:
---
gcc/testsuite/ChangeLog | 5 ++++
gcc/testsuite/g++.dg/warn/Wstringop-overflow-5.C | 37 ++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8610164..279ab64 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-28 Martin Sebor <msebor@redhat.com>
+
+ PR middle-end/93437
+ * g++.dg/warn/Wstringop-overflow-5.C: New test.a
+
2020-01-28 Jan Hubicka <hubicka@ucw.cz>
* g++.dg/tree-prof/indir-call-prof.C: Update template.
diff --git a/gcc/testsuite/g++.dg/warn/Wstringop-overflow-5.C b/gcc/testsuite/g++.dg/warn/Wstringop-overflow-5.C
new file mode 100644
index 0000000..3e905fc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wstringop-overflow-5.C
@@ -0,0 +1,37 @@
+/* PR middle-end/93437 - bogus -Warray-bounds on protobuf generated code
+ { dg-do compile }
+ { dg-options "-O3 -Wall" } */
+
+typedef __SIZE_TYPE__ size_t;
+typedef __UINT32_TYPE__ uint32_t;
+
+inline void* operator new (size_t, void* p)
+{
+ return p;
+}
+
+extern "C" void* memset(void*, int, size_t);
+
+struct Bucket {
+ Bucket ();
+ uint32_t _has_bits_;
+ uint32_t cumulative_count_;
+ uint32_t upper_bound_;
+};
+
+extern Bucket _Bucket_default_instance_;
+
+Bucket::Bucket ()
+{
+ memset (&_has_bits_, 0, sizeof _has_bits_);
+ memset (&cumulative_count_, 0, // { dg-bogus "\\\[-Warray-bounds|-wstringop-overflow" }
+ static_cast<size_t>(reinterpret_cast<char*>(&upper_bound_)
+ - reinterpret_cast<char*>(&cumulative_count_))
+ + sizeof upper_bound_);
+}
+
+void* InitDefaultsBucket ()
+{
+ void* ptr = &::_Bucket_default_instance_;
+ return new (ptr)::Bucket();
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-01-31 17:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-31 17:49 [gcc/devel/c++-modules] PR middle-end/93437 - bogus -Warray-bounds on protobuf generated code Nathan Sidwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).