diff options
author | Derek Mauro <dmauro@google.com> | 2022-06-15 07:53:43 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-06-15 07:54:31 -0700 |
commit | 509f275822e8158bf76a9b24830a8de9d2fdfef2 (patch) | |
tree | 709fc747fda4706d751d367a5128ab2cc06c24cf /absl | |
parent | a184bab83ffcffc2aaac49a3900361158ab3890f (diff) |
explicit_seed_seq_test: work around/disable bogus warnings in GCC 12
PiperOrigin-RevId: 455129922
Change-Id: I3b2a62cbf50057b3ea9b73c2edb44271dc46986c
Diffstat (limited to 'absl')
-rw-r--r-- | absl/random/internal/explicit_seed_seq_test.cc | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/absl/random/internal/explicit_seed_seq_test.cc b/absl/random/internal/explicit_seed_seq_test.cc index f867f610..e36d5fa0 100644 --- a/absl/random/internal/explicit_seed_seq_test.cc +++ b/absl/random/internal/explicit_seed_seq_test.cc @@ -140,10 +140,8 @@ TEST(ExplicitSeedSeq, CopyAndMoveConstructors) { ExplicitSeedSeq seq_copy(seq_from_entropy); EXPECT_EQ(seq_copy.size(), seq_from_entropy.size()); - std::vector<uint32_t> seeds_1; - seeds_1.resize(1000, 0); - std::vector<uint32_t> seeds_2; - seeds_2.resize(1000, 1); + std::vector<uint32_t> seeds_1(1000, 0); + std::vector<uint32_t> seeds_2(1000, 1); seq_from_entropy.generate(seeds_1.begin(), seeds_1.end()); seq_copy.generate(seeds_2.begin(), seeds_2.end()); @@ -157,10 +155,8 @@ TEST(ExplicitSeedSeq, CopyAndMoveConstructors) { } ExplicitSeedSeq another_seq(std::begin(entropy), std::end(entropy)); - std::vector<uint32_t> seeds_1; - seeds_1.resize(1000, 0); - std::vector<uint32_t> seeds_2; - seeds_2.resize(1000, 0); + std::vector<uint32_t> seeds_1(1000, 0); + std::vector<uint32_t> seeds_2(1000, 0); seq_from_entropy.generate(seeds_1.begin(), seeds_1.end()); another_seq.generate(seeds_2.begin(), seeds_2.end()); @@ -169,7 +165,15 @@ TEST(ExplicitSeedSeq, CopyAndMoveConstructors) { EXPECT_THAT(seeds_1, Not(Pointwise(Eq(), seeds_2))); // Apply the assignment-operator. + // GCC 12 has a false-positive -Wstringop-overflow warning here. +#if ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(12, 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif another_seq = seq_from_entropy; +#if ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(12, 0) +#pragma GCC diagnostic pop +#endif // Re-generate seeds. seq_from_entropy.generate(seeds_1.begin(), seeds_1.end()); @@ -181,15 +185,13 @@ TEST(ExplicitSeedSeq, CopyAndMoveConstructors) { // Move constructor. { // Get seeds from seed-sequence constructed from entropy. - std::vector<uint32_t> seeds_1; - seeds_1.resize(1000, 0); + std::vector<uint32_t> seeds_1(1000, 0); seq_from_entropy.generate(seeds_1.begin(), seeds_1.end()); // Apply move-constructor move the sequence to another instance. absl::random_internal::ExplicitSeedSeq moved_seq( std::move(seq_from_entropy)); - std::vector<uint32_t> seeds_2; - seeds_2.resize(1000, 1); + std::vector<uint32_t> seeds_2(1000, 1); moved_seq.generate(seeds_2.begin(), seeds_2.end()); // Verify that seeds produced by moved-instance are the same as original. EXPECT_THAT(seeds_1, Pointwise(Eq(), seeds_2)); |