diff options
author | Derek Mauro <dmauro@google.com> | 2022-06-06 07:43:30 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-06-06 07:44:19 -0700 |
commit | 9cdb98e73118f0485fdf5fadcb3e57ab852e65a1 (patch) | |
tree | 2377b06a10f1af097e71797fc630ef37418bec50 /absl/container/inlined_vector.h | |
parent | 47345f63b94a0ea8fbfb3c49ed5b185f2b649f1a (diff) | |
download | abseil-9cdb98e73118f0485fdf5fadcb3e57ab852e65a1.tar.gz abseil-9cdb98e73118f0485fdf5fadcb3e57ab852e65a1.tar.bz2 abseil-9cdb98e73118f0485fdf5fadcb3e57ab852e65a1.zip |
InlinedVector: Limit the scope of the maybe-uninitialized warning suppression
Due to changes in GCC 12, without this change, the warning fires
PiperOrigin-RevId: 453197246
Change-Id: I2e31cbff1707ab09868cf77dcf040b033984e654
Diffstat (limited to 'absl/container/inlined_vector.h')
-rw-r--r-- | absl/container/inlined_vector.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h index 711b29c1..bc1c4a77 100644 --- a/absl/container/inlined_vector.h +++ b/absl/container/inlined_vector.h @@ -585,8 +585,20 @@ class InlinedVector { if (ABSL_PREDICT_TRUE(n != 0)) { value_type dealias = v; + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102329#c2 + // It appears that GCC thinks that since `pos` is a const pointer and may + // point to uninitialized memory at this point, a warning should be + // issued. But `pos` is actually only used to compute an array index to + // write to. +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif return storage_.Insert(pos, CopyValueAdapter<A>(std::addressof(dealias)), n); +#if !defined(__clang__) && defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } else { return const_cast<iterator>(pos); } |