Skip to content

Commit

Permalink
[MISC] Use SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_{START,STOP}
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Oct 30, 2024
1 parent 1ebcaf4 commit 4c736c8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,9 @@ inline void assign_unaligned(aligned_seq_t & aligned_seq, unaligned_sequence_typ
using std::swap;
aligned_seq_t tmp;
tmp.resize(std::ranges::distance(unaligned_seq));
#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wstringop-overflow)
std::ranges::copy(unaligned_seq, std::ranges::begin(tmp));
#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic pop
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP
swap(aligned_seq, tmp);
}
//!\}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,9 @@ class score_matrix_single_column
this->number_of_columns = number_of_columns.get();
optimal_column.clear();
horizontal_column.clear();
#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wstringop-overflow)
optimal_column.resize(number_of_rows.get(), initial_value);
#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic pop
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP
horizontal_column.resize(number_of_rows.get(), initial_value);
vertical_column = views::repeat_n(initial_value, number_of_rows.get());
}
Expand Down
12 changes: 4 additions & 8 deletions include/seqan3/alphabet/container/concatenated_sequences.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,9 @@ class concatenated_sequences
reference operator[](size_type const i)
{
assert(i < size());
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Warray-bounds)
return data_values | views::slice(data_delimiters[i], data_delimiters[i + 1]);
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP
}

//!\copydoc operator[]()
Expand Down Expand Up @@ -977,17 +979,11 @@ class concatenated_sequences
auto placeholder =
views::repeat_n(std::ranges::range_value_t<rng_type>{}, count * value_len) | std::views::common;
// insert placeholder so the tail is moved once:
#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstringop-overread"
# pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wstringop-overread, -Wstringop-overflow)
data_values.insert(data_values.begin() + data_delimiters[pos_as_num],
std::ranges::begin(placeholder),
std::ranges::end(placeholder));
#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic pop
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP

// assign the actual values to the placeholder:
size_t i = data_delimiters[pos_as_num];
Expand Down
9 changes: 2 additions & 7 deletions include/seqan3/utility/container/small_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,14 +735,9 @@ class small_vector
for (size_type i = sz + length - 1; i > pos_as_num + length - 1; --i)
data_[i] = data_[i - length];

#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wstringop-overflow)
std::ranges::copy(begin_it, end_it, &data_[pos_as_num]);
#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic pop
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP
sz += length;
return begin() + pos_as_num;
}
Expand Down
31 changes: 8 additions & 23 deletions test/unit/alphabet/container/container_concept_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,15 @@ TEST(container, sequence_container_former_travis_bug)
s.insert(0, 1, 'E');
EXPECT_EQ("Exmplr", s);

#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wrestrict"
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wrestrict)
// insert(size_type index, const char* s)
s.insert(2, "e");
EXPECT_EQ("Exemplr", s);

// insert(size_type index, string const& str)
s.insert(6, "a"s);
EXPECT_EQ("Exemplar", s);
#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic pop
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP

// insert(size_type index, string const& str, size_type index_str, size_type count)
s.insert(8, " is an example string."s, 0, 14);
Expand All @@ -99,17 +94,12 @@ TEST(container, sequence_container_former_travis_bug)
EXPECT_EQ("Exemplar is an:== example string", s);
}

# if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wrestrict"
# endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wrestrict)
// insert(const_iterator pos, std::initializer_list<char>)
s.insert(s.begin() + s.find_first_of('g') + 1, {'.'});
EXPECT_EQ("Exemplar is an:== example string.", s);
# if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic pop
# endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
#else // ^^^ workaround / no workaround vvv
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP
#else // ^^^ workaround / no workaround vvv
// insert(const_iterator pos, char ch)
s.insert(s.cbegin() + s.find_first_of('n') + 1, ':');
EXPECT_EQ("Exemplar is an: example", s);
Expand All @@ -126,16 +116,11 @@ TEST(container, sequence_container_former_travis_bug)
}

// insert(const_iterator pos, std::initializer_list<char>)
# if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wrestrict"
# endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Wrestrict)
s.insert(s.cbegin() + s.find_first_of('g') + 1, {'.'});
EXPECT_EQ("Exemplar is an:== example string.", s);
# if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic pop
# endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
#endif // SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP
#endif // SEQAN3_WORKAROUND_GCC_NO_CXX11_ABI
}

TEST(container, sequence_container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ TYPED_TEST_SUITE(debug_stream_test, container_of_container_types, );

TYPED_TEST(debug_stream_test, container_of_container)
{
#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Warray-bounds"
# pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_START(-Warray-bounds, -Wstringop-overflow)
TypeParam t1{"ACGT"_dna4, "ACGT"_dna4, "GAGGA"_dna4};
#if SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
# pragma GCC diagnostic pop
#endif // SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY
SEQAN3_WORKAROUND_GCC_BOGUS_MEMCPY_STOP

std::ostringstream o;
seqan3::debug_stream_type my_stream{o};
Expand Down

0 comments on commit 4c736c8

Please sign in to comment.