Skip to content

Commit

Permalink
Disable more false positive warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph-Edwards committed Sep 18, 2024
1 parent 7f80994 commit ec68e82
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
10 changes: 10 additions & 0 deletions include/libsemigroups/detail/containers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,18 @@ namespace libsemigroups {

// Not noexcept because std::array::operator[] isn't
void push_back(T x) {
// The below assertions exist to insure that we are not badly assigning
// values. The subsequent pragmas exist to suppress the false-positive
// warnings produced by g++ 13.2.0
LIBSEMIGROUPS_ASSERT(_size < N);
LIBSEMIGROUPS_ASSERT(_array.size() == N);
static_assert(std::is_same_v<typename decltype(_array)::value_type, T>);
#pragma GCC diagnostic push
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
_array[_size] = x;
#pragma GCC diagnostic pop
_size++;
}

Expand Down
25 changes: 24 additions & 1 deletion include/libsemigroups/presentation.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,20 @@ namespace libsemigroups {
}
}
word_type lphbt(n, 0);

// The below assertions exist to insure that we are not badly assigning
// values. The subsequent pragmas exist to suppress the false-positive
// warnings produced by g++ 13.2.0
static_assert(
std::is_same_v<std::decay_t<decltype(*lphbt.begin())>,
decltype(words::human_readable_letter<Word>(0))>);
#pragma GCC diagnostic push
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
std::iota(
lphbt.begin(), lphbt.end(), words::human_readable_letter<Word>(0));

#pragma GCC diagnostic pop
return alphabet(lphbt);
}

Expand Down Expand Up @@ -655,9 +666,21 @@ namespace libsemigroups {
}
Word A(p.alphabet().size(), 0);

// The below assertion exists to insure that we are not badly assigning
// values. The subsequent pragmas exist to suppress the false-positive
// warnings produced by g++ 13.2.0
static_assert(
std::is_same_v<typename Word::value_type,
decltype(words::human_readable_letter<Word>(0))>);

#pragma GCC diagnostic push
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
for (size_t i = 0; i < p.alphabet().size(); ++i) {
A[i] = words::human_readable_letter<Word>(i);
}
#pragma GCC diagnostic pop
p.alphabet(std::move(A));
#ifdef LIBSEMIGROUPS_DEBUG
p.validate();
Expand Down
8 changes: 8 additions & 0 deletions include/libsemigroups/to-presentation.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,15 @@ namespace libsemigroups {
presentation::normalize_alphabet(result);
result.alphabet(2 * result.alphabet().size());
auto invs = result.alphabet();

// The below pragma exists to suppress the false-positive warnings produced
// by g++ 13.2.0
#pragma GCC diagnostic push
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
std::rotate(invs.begin(), invs.begin() + invs.size() / 2, invs.end());
#pragma GCC diagnostic pop
result.inverses_no_checks(std::move(invs));
return result;
}
Expand Down
10 changes: 10 additions & 0 deletions include/libsemigroups/transf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,23 @@ namespace libsemigroups {
template <typename Iterator>
explicit PTransfBase(Iterator first, Iterator last) : PTransfBase() {
using OtherScalar = typename std::iterator_traits<Iterator>::value_type;
// The below assertions exist to insure that we are not badly assigning
// values. The subsequent pragmas exist to suppress the false-positive
// warnings produced by g++ 13.2.0
static_assert(
std::is_same_v<OtherScalar, Undefined>
|| std::is_convertible_v<OtherScalar, point_type>,
"the template parameter Iterator must have "
"value_type \"Undefined\" or convertible to \"point_type\"!");
static_assert(std::is_same_v<std::decay_t<decltype(*_container.begin())>,
point_type>);
resize(_container, std::distance(first, last));
#pragma GCC diagnostic push
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
std::copy(first, last, _container.begin());
#pragma GCC diagnostic pop
}

//! \copydoc PTransfBase::PTransfBase(Container const&)
Expand Down

0 comments on commit ec68e82

Please sign in to comment.