Skip to content

Commit e69d872

Browse files
committed
test: ignore self-move warning in buffer unit test
The new warning forbids to move an objects to itself - in our case, it's the purpose of the case, so let's ignore the warning there. The problem failed build on `ubuntu-24.04` GitHub Actions runner.
1 parent a63dae3 commit e69d872

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/BufferUnitTest.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,23 @@ auto itr_at(BUF &buf, size_t pos)
613613
return itr;
614614
}
615615

616+
/** A helper to move buffer to itself - disables warning on GCC compiler. */
617+
template<class Buffer>
618+
static inline void
619+
buffer_move_to_self(Buffer &buf)
620+
{
621+
#ifdef __GNUC__
622+
#pragma GCC diagnostic push
623+
#pragma GCC diagnostic ignored "-Wself-move"
624+
#endif
625+
626+
buf = std::move(buf);
627+
628+
#ifdef __GNUC__
629+
#pragma GCC diagnostic pop
630+
#endif
631+
}
632+
616633
/**
617634
* Test move constructor and assignment.
618635
*/
@@ -626,7 +643,7 @@ buffer_move()
626643
tnt::Buffer<N> buf1;
627644
fillBuffer(buf1, S);
628645
/* It is ok to move to itself. */
629-
buf1 = std::move(buf1);
646+
buffer_move_to_self(buf1);
630647

631648
/* Create three iterators pointing to different parts. */
632649
auto itr0 = buf1.begin();
@@ -655,7 +672,7 @@ buffer_move()
655672
fail_unless(!buf1.has(buf1.begin(), S + ins_cnt + 1));
656673

657674
/* It is ok to move to itself. */
658-
buf1 = std::move(buf1);
675+
buffer_move_to_self(buf1);
659676
fail_unless(itr0 == buf1.begin());
660677
fail_unless(itr1 == itr_at(buf1, 1 + ins_cnt));
661678
fail_unless(itr2 == itr_at(buf1, S / 2 + ins_cnt));

0 commit comments

Comments
 (0)