Skip to content

Commit 915477b

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 8d303a9 commit 915477b

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

test/BufferUnitTest.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,24 @@ 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 BUF>
618+
static inline void
619+
buffer_move_to_self(BUF &buf)
620+
{
621+
/* Self-move warning was introduced in GCC 13. */
622+
#if __GNUC__ >= 13
623+
#pragma GCC diagnostic push
624+
#pragma GCC diagnostic ignored "-Wself-move"
625+
#endif
626+
627+
buf = std::move(buf);
628+
629+
#if __GNUC__ >= 13
630+
#pragma GCC diagnostic pop
631+
#endif
632+
}
633+
616634
/**
617635
* Test move constructor and assignment.
618636
*/
@@ -626,7 +644,7 @@ buffer_move()
626644
tnt::Buffer<N> buf1;
627645
fillBuffer(buf1, S);
628646
/* It is ok to move to itself. */
629-
buf1 = std::move(buf1);
647+
buffer_move_to_self(buf1);
630648

631649
/* Create three iterators pointing to different parts. */
632650
auto itr0 = buf1.begin();
@@ -655,7 +673,7 @@ buffer_move()
655673
fail_unless(!buf1.has(buf1.begin(), S + ins_cnt + 1));
656674

657675
/* It is ok to move to itself. */
658-
buf1 = std::move(buf1);
676+
buffer_move_to_self(buf1);
659677
fail_unless(itr0 == buf1.begin());
660678
fail_unless(itr1 == itr_at(buf1, 1 + ins_cnt));
661679
fail_unless(itr2 == itr_at(buf1, S / 2 + ins_cnt));

0 commit comments

Comments
 (0)