diff --git a/.github/actions/build-tntcxx/action.yml b/.github/actions/build-tntcxx/action.yml index 369324d18..dba8f8cef 100644 --- a/.github/actions/build-tntcxx/action.yml +++ b/.github/actions/build-tntcxx/action.yml @@ -29,6 +29,7 @@ runs: -DTNTCXX_ENABLE_SANITIZERS=${{ inputs.enable-sanitizers }} \ -DCMAKE_CXX_STANDARD=${{ inputs.cxx-standard }} \ -DCMAKE_C_COMPILER=${{ inputs.c-compiler }} \ - -DCMAKE_CXX_COMPILER=${{ inputs.cxx-compiler }} + -DCMAKE_CXX_COMPILER=${{ inputs.cxx-compiler }} \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 make -j shell: bash diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index d67566278..fbbe11654 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -14,8 +14,8 @@ jobs: fail-fast: false matrix: runs-on: - - ubuntu-20.04 - ubuntu-22.04 + - ubuntu-24.04 - macos-13 - macos-14 - macos-15 @@ -35,8 +35,8 @@ jobs: fail-fast: false matrix: runs-on: - - ubuntu-20.04 - ubuntu-22.04 + - ubuntu-24.04 - macos-13 - macos-14 - macos-15 diff --git a/src/Buffer/Buffer.hpp b/src/Buffer/Buffer.hpp index 459af3335..68f405578 100644 --- a/src/Buffer/Buffer.hpp +++ b/src/Buffer/Buffer.hpp @@ -1362,7 +1362,7 @@ std::string dump(Buffer &buffer) { size_t vec_len = 0; - size_t IOVEC_MAX = 1024; + constexpr size_t IOVEC_MAX = 1024; size_t block_cnt = 0; struct iovec vec[IOVEC_MAX]; std::string output; diff --git a/src/Client/ResponseReader.hpp b/src/Client/ResponseReader.hpp index 8b213c9af..3cac8dc8d 100644 --- a/src/Client/ResponseReader.hpp +++ b/src/Client/ResponseReader.hpp @@ -102,10 +102,10 @@ struct Data { /** Unpacks tuples to passed container. */ template - bool decode(T& tuples) + bool decode(T&& tuples) { it_t itr = iters.first; - bool ok = mpp::decode(itr, tuples); + bool ok = mpp::decode(itr, std::forward(tuples)); assert(!ok || itr == iters.second); return ok; } diff --git a/test/BufferUnitTest.cpp b/test/BufferUnitTest.cpp index 9a63c72da..acf678d0c 100644 --- a/test/BufferUnitTest.cpp +++ b/test/BufferUnitTest.cpp @@ -71,7 +71,7 @@ template static void eraseBuffer(tnt::Buffer &buffer) { - int IOVEC_MAX = 1024; + constexpr int IOVEC_MAX = 1024; struct iovec vec[IOVEC_MAX]; do { size_t vec_size = buffer.getIOV(buffer.begin(), vec, IOVEC_MAX); @@ -89,7 +89,7 @@ static void dumpBuffer(tnt::Buffer &buffer, std::string &output) { size_t vec_len = 0; - int IOVEC_MAX = 1024; + constexpr int IOVEC_MAX = 1024; size_t block_cnt = 0; struct iovec vec[IOVEC_MAX]; for (auto itr = buffer.begin(); itr != buffer.end(); itr += vec_len) { @@ -575,7 +575,7 @@ buffer_out() fail_if(buf.debugSelfCheck()); save.unlink(); do { - int IOVEC_MAX = 1024; + constexpr int IOVEC_MAX = 1024; struct iovec vec[IOVEC_MAX]; size_t vec_size = buf.getIOV(buf.begin(), vec, IOVEC_MAX); buf.dropFront(vec_size); @@ -592,7 +592,7 @@ buffer_iterator_get() { TEST_INIT(1, N); tnt::Buffer buf; - size_t DATA_SIZE = SAMPLES_CNT * 10; + constexpr size_t DATA_SIZE = SAMPLES_CNT * 10; fillBuffer(buf, DATA_SIZE); buf.write(end_marker); fail_if(buf.debugSelfCheck()); @@ -613,6 +613,24 @@ auto itr_at(BUF &buf, size_t pos) return itr; } +/** A helper to move buffer to itself - disables warning on GCC compiler. */ +template +static inline void +buffer_move_to_self(BUF &buf) +{ +/* Self-move warning was introduced in GCC 13. */ +#if __GNUC__ >= 13 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wself-move" +#endif + + buf = std::move(buf); + +#if __GNUC__ >= 13 +#pragma GCC diagnostic pop +#endif +} + /** * Test move constructor and assignment. */ @@ -626,7 +644,7 @@ buffer_move() tnt::Buffer buf1; fillBuffer(buf1, S); /* It is ok to move to itself. */ - buf1 = std::move(buf1); + buffer_move_to_self(buf1); /* Create three iterators pointing to different parts. */ auto itr0 = buf1.begin(); @@ -655,7 +673,7 @@ buffer_move() fail_unless(!buf1.has(buf1.begin(), S + ins_cnt + 1)); /* It is ok to move to itself. */ - buf1 = std::move(buf1); + buffer_move_to_self(buf1); fail_unless(itr0 == buf1.begin()); fail_unless(itr1 == itr_at(buf1, 1 + ins_cnt)); fail_unless(itr2 == itr_at(buf1, S / 2 + ins_cnt)); diff --git a/test/ClientTest.cpp b/test/ClientTest.cpp index 0fdde8c29..16adbafa0 100644 --- a/test/ClientTest.cpp +++ b/test/ClientTest.cpp @@ -1125,6 +1125,17 @@ response_decoding(Connector &client) fail_if(response->body.data->decode(arr_of_str)); /* We should successfully decode data after all. */ fail_unless(response->body.data->decode(arr_of_num)); + fail_unless(std::get<0>(arr_of_num) == 666); + + TEST_CASE("decode data to rvalue object"); + num = 0; + fail_unless(response->body.data->decode(std::forward_as_tuple(num))); + fail_unless(num == 666); + + TEST_CASE("decode data to object with an mpp tag"); + std::get<0>(arr_of_num) = 0; + fail_unless(response->body.data->decode(mpp::as_arr(arr_of_num))); + fail_unless(std::get<0>(arr_of_num) == 666); client.close(conn); }