From 025fc007b893acc3ac224c78d15c3ac2a03defc9 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sat, 11 Nov 2023 17:55:27 +0100 Subject: [PATCH 1/6] iox-#2047 Fix 'stringop-overflow' warning in 'string.inl' --- .../vocabulary/include/iox/detail/string.inl | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl b/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl index d3becd9a12..5726ca4c98 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl @@ -1,5 +1,6 @@ // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. // Copyright (c) 2021 - 2023 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2023 by Mathias Kraus . All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -164,17 +165,35 @@ inline string& string::operator=(const char (&rhs)[N]) noexc return *this; } - std::memcpy(m_rawstring, rhs, N); + const auto sourceRawStringSize = static_cast(strnlen(&rhs[0], N)); + if (sourceRawStringSize <= Capacity) + { + m_rawstringSize = sourceRawStringSize; + } + else + { + m_rawstringSize = Capacity; + + IOX_LOG( + WARN, + "iox::string: Assignment of array which is not zero-terminated! Last value of array overwritten with 0!"); + } + + // AXIVION DISABLE STYLE AutosarC++19_03-A16.0.1: pre-processor is required for setting gcc diagnostics, since gcc 8 incorrectly warns here about out of bounds array access + // AXIVION DISABLE STYLE AutosarC++19_03-A16.7.1: see rule 'A16.0.1' above +#if (defined(__GNUC__) && (__GNUC__ == 8)) && (__GNUC_MINOR__ >= 3) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif + std::memcpy(m_rawstring, rhs, m_rawstringSize); +#if (defined(__GNUC__) && (__GNUC__ == 8)) && (__GNUC_MINOR__ >= 3) +#pragma GCC diagnostic pop +#endif + // AXIVION ENABLE STYLE AutosarC++19_03-A16.7.1 + // AXIVION ENABLE STYLE AutosarC++19_03-A16.0.1 - m_rawstringSize = std::min(Capacity, static_cast(strnlen(&rhs[0], N))); m_rawstring[m_rawstringSize] = '\0'; - if (rhs[m_rawstringSize] != '\0') - { - IOX_LOG(WARN, - "iox::string: Assignment of array which is not zero-terminated! Last value of array " - "overwritten with 0!"); - } return *this; } From d88ab623b29096766b191578170d1df203fff7bd Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sat, 11 Nov 2023 17:55:51 +0100 Subject: [PATCH 2/6] iox-#2047 Fix 'self-move' warning in string tests --- iceoryx_hoofs/test/moduletests/test_vocabulary_string.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/iceoryx_hoofs/test/moduletests/test_vocabulary_string.cpp b/iceoryx_hoofs/test/moduletests/test_vocabulary_string.cpp index 78d06b9e49..a6b6b6bd27 100644 --- a/iceoryx_hoofs/test/moduletests/test_vocabulary_string.cpp +++ b/iceoryx_hoofs/test/moduletests/test_vocabulary_string.cpp @@ -186,7 +186,14 @@ TYPED_TEST(stringTyped_test, SelfMoveAssignmentExcluded) { ::testing::Test::RecordProperty("TEST_ID", "0ad45975-b68b-465a-b8c5-83dd8d8290d5"); this->testSubject = "M"; +#if (defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wself-move" +#endif this->testSubject = std::move(this->testSubject); +#if (defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)) +#pragma GCC diagnostic pop +#endif EXPECT_THAT(this->testSubject.size(), Eq(1U)); EXPECT_THAT(this->testSubject.c_str(), StrEq("M")); } From 825e2bb8813049744e8fd70f2148928584a66c07 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sat, 11 Nov 2023 18:52:27 +0100 Subject: [PATCH 3/6] iox-#2047 Fix 'stringop-overflow' warning in variant queue --- .../iceoryx_hoofs/cxx/variant_queue.hpp | 2 +- .../internal/cxx/variant_queue.inl | 132 ++++++++++-------- .../vocabulary/include/iox/detail/variant.inl | 20 +++ .../vocabulary/include/iox/variant.hpp | 20 +++ 4 files changed, 114 insertions(+), 60 deletions(-) diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant_queue.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant_queue.hpp index cf0ef1afec..3c821a0987 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant_queue.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant_queue.hpp @@ -113,7 +113,7 @@ class VariantQueue uint64_t capacity() const noexcept; private: - VariantQueueTypes m_type; + const VariantQueueTypes m_type; fifo_t m_fifo; }; } // namespace cxx diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_queue.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_queue.inl index 1c92ea561f..0c838de273 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_queue.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_queue.inl @@ -1,5 +1,6 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. // Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2023 by Mathias Kraus . All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -56,34 +57,38 @@ optional VariantQueue::push(const ValueType& val { case VariantQueueTypes::FiFo_SingleProducerSingleConsumer: { - auto hadSpace = - m_fifo.template get_at_index(VariantQueueTypes::FiFo_SingleProducerSingleConsumer)>() - ->push(value); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_SingleProducerSingleConsumer)>(); + auto hadSpace = queue->push(value); return (hadSpace) ? nullopt : make_optional(value); } case VariantQueueTypes::SoFi_SingleProducerSingleConsumer: { ValueType overriddenValue; - auto hadSpace = - m_fifo.template get_at_index(VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>() - ->push(value, overriddenValue); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>(); + auto hadSpace = queue->push(value, overriddenValue); return (hadSpace) ? nullopt : make_optional(overriddenValue); } case VariantQueueTypes::FiFo_MultiProducerSingleConsumer: { - auto hadSpace = - m_fifo.template get_at_index(VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>() - ->tryPush(value); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>(); + auto hadSpace = queue->tryPush(value); return (hadSpace) ? nullopt : make_optional(value); } case VariantQueueTypes::SoFi_MultiProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>() - ->push(value); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>(); + return queue->push(value); } } @@ -97,25 +102,28 @@ inline optional VariantQueue::pop() noexcept { case VariantQueueTypes::FiFo_SingleProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::FiFo_SingleProducerSingleConsumer)>() - ->pop(); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_SingleProducerSingleConsumer)>(); + return queue->pop(); } case VariantQueueTypes::SoFi_SingleProducerSingleConsumer: { ValueType returnType; - auto hasReturnType = - m_fifo.template get_at_index(VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>() - ->pop(returnType); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>(); + auto hasReturnType = queue->pop(returnType); return (hasReturnType) ? make_optional(returnType) : nullopt; } case VariantQueueTypes::FiFo_MultiProducerSingleConsumer: case VariantQueueTypes::SoFi_MultiProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>() - ->pop(); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>(); + return queue->pop(); } } @@ -129,22 +137,25 @@ inline bool VariantQueue::empty() const noexcept { case VariantQueueTypes::FiFo_SingleProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::FiFo_SingleProducerSingleConsumer)>() - ->empty(); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_SingleProducerSingleConsumer)>(); + return queue->empty(); } case VariantQueueTypes::SoFi_SingleProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>() - ->empty(); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>(); + return queue->empty(); } case VariantQueueTypes::FiFo_MultiProducerSingleConsumer: case VariantQueueTypes::SoFi_MultiProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>() - ->empty(); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>(); + return queue->empty(); } } @@ -158,25 +169,25 @@ inline uint64_t VariantQueue::size() noexcept { case VariantQueueTypes::FiFo_SingleProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::FiFo_SingleProducerSingleConsumer)>() - ->size(); - break; + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_SingleProducerSingleConsumer)>(); + return queue->size(); } case VariantQueueTypes::SoFi_SingleProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>() - ->size(); - break; + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>(); + return queue->size(); } case VariantQueueTypes::FiFo_MultiProducerSingleConsumer: case VariantQueueTypes::SoFi_MultiProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>() - ->size(); - break; + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>(); + return queue->size(); } } @@ -197,17 +208,20 @@ inline bool VariantQueue::setCapacity(const uint64_t newCap } case VariantQueueTypes::SoFi_SingleProducerSingleConsumer: { - m_fifo.template get_at_index(VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>() - ->setCapacity(newCapacity); + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>(); + queue->setCapacity(newCapacity); return true; } case VariantQueueTypes::FiFo_MultiProducerSingleConsumer: case VariantQueueTypes::SoFi_MultiProducerSingleConsumer: { + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>(); // we may discard elements in the queue if the size is reduced and the fifo contains too many elements - return m_fifo - .template get_at_index(VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>() - ->setCapacity(newCapacity); + return queue->setCapacity(newCapacity); } } return false; @@ -220,25 +234,25 @@ inline uint64_t VariantQueue::capacity() const noexcept { case VariantQueueTypes::FiFo_SingleProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::FiFo_SingleProducerSingleConsumer)>() - ->capacity(); - break; + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_SingleProducerSingleConsumer)>(); + return queue->capacity(); } case VariantQueueTypes::SoFi_SingleProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>() - ->capacity(); - break; + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>(); + return queue->capacity(); } case VariantQueueTypes::FiFo_MultiProducerSingleConsumer: case VariantQueueTypes::SoFi_MultiProducerSingleConsumer: { - return m_fifo - .template get_at_index(VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>() - ->capacity(); - break; + // SAFETY: 'm_type' ist 'const' and does not change after construction + auto* queue = m_fifo.template unsafe_get_at_index_unchecked( + VariantQueueTypes::FiFo_MultiProducerSingleConsumer)>(); + return queue->capacity(); } } diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/variant.inl b/iceoryx_hoofs/vocabulary/include/iox/detail/variant.inl index 4c7c40e00b..3cde2ce018 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/variant.inl +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/variant.inl @@ -1,6 +1,7 @@ // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. // Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // Copyright (c) 2021 by Perforce All rights reserved. +// Copyright (c) 2023 by Mathias Kraus . All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -204,6 +205,14 @@ inline typename internal::get_type_at_index<0, TypeIndex, Types...>::type* varia return nullptr; } + return unsafe_get_at_index_unchecked(); +} + +template +template +inline typename internal::get_type_at_index<0, TypeIndex, Types...>::type* +variant::unsafe_get_at_index_unchecked() noexcept +{ using T = typename internal::get_type_at_index<0, TypeIndex, Types...>::type; // AXIVION Next Construct AutosarC++19_03-M5.2.8 : conversion to typed pointer is intentional, it is correctly aligned and points to sufficient memory for a T by design @@ -221,6 +230,17 @@ variant::get_at_index() const noexcept return const_cast(const_cast(this)->template get_at_index()); } +template +template +inline const typename internal::get_type_at_index<0, TypeIndex, Types...>::type* +variant::unsafe_get_at_index_unchecked() const noexcept +{ + using T = typename internal::get_type_at_index<0, TypeIndex, Types...>::type; + // AXIVION Next Construct AutosarC++19_03-A5.2.3 : avoid code duplication + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) + return const_cast(const_cast(this)->template unsafe_get_at_index_unchecked()); +} + template template inline const T* variant::get() const noexcept diff --git a/iceoryx_hoofs/vocabulary/include/iox/variant.hpp b/iceoryx_hoofs/vocabulary/include/iox/variant.hpp index f142659539..c445568a61 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/variant.hpp +++ b/iceoryx_hoofs/vocabulary/include/iox/variant.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. // Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2023 by Mathias Kraus . All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -212,6 +213,15 @@ class variant final template typename internal::get_type_at_index<0, TypeIndex, Types...>::type* get_at_index() noexcept; + /// @brief returns a pointer to the type stored at index TypeIndex. (not stl compliant) + /// @tparam[in] TypeIndex index of the stored type + /// @return a pointer to the type at index + /// @attention this function is unsafe and does not check if the type at the index is the current active one; only + /// use this function when it is ensured that the type at index is indeed the current active one; it is undefined + /// behavior to call this on an index which is not the active type + template + typename internal::get_type_at_index<0, TypeIndex, Types...>::type* unsafe_get_at_index_unchecked() noexcept; + /// @brief returns a pointer to the type stored at index TypeIndex. (not stl compliant) /// @tparam[in] TypeIndex index of the stored type /// @return if the variant does contain the type at index TypeIndex it returns a valid @@ -224,6 +234,16 @@ class variant final template const typename internal::get_type_at_index<0, TypeIndex, Types...>::type* get_at_index() const noexcept; + /// @brief returns a pointer to the type stored at index TypeIndex. (not stl compliant) + /// @tparam[in] TypeIndex index of the stored type + /// @return a const pointer to the type at index + /// @attention this function is unsafe and does not check if the type at the index is the current active one; only + /// use this function when it is ensured that the type at index is indeed the current active one; it is undefined + /// behavior to call this on an index which is not the active type + template + const typename internal::get_type_at_index<0, TypeIndex, Types...>::type* + unsafe_get_at_index_unchecked() const noexcept; + /// @brief returns a pointer to the type T stored in the variant. (not stl compliant) /// @tparam[in] T type of the returned pointer /// @return if the variant does contain the type T it returns a valid pointer otherwise From 4aadeb53840502591bd4476d82b1d783c55082d5 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sat, 11 Nov 2023 18:54:58 +0100 Subject: [PATCH 4/6] iox-#2047 Fix 'array-bounds' warning in chunk distributor --- .../building_blocks/chunk_distributor.hpp | 2 + .../building_blocks/chunk_distributor.inl | 51 +++++++++++-------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_distributor.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_distributor.hpp index 9e7e35f3b8..f193c6205b 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_distributor.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_distributor.hpp @@ -24,6 +24,8 @@ #include "iox/detail/unique_id.hpp" #include "iox/not_null.hpp" +#include +#include #include namespace iox diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_distributor.inl b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_distributor.inl index 2db654d8dc..f4dda63afd 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_distributor.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_distributor.inl @@ -1,5 +1,6 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. // Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2023 by Mathias Kraus . All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -140,7 +141,8 @@ template inline uint64_t ChunkDistributor::deliverToAllStoredQueues(mepoo::SharedChunk chunk) noexcept { uint64_t numberOfQueuesTheChunkWasDeliveredTo{0U}; - typename ChunkDistributorDataType::QueueContainer_t remainingQueues; + using QueueContainer = decltype(getMembers()->m_queues); + QueueContainer fullQueuesAwaitingDelivery; { typename MemberType_t::LockGuard_t lock(*getMembers()); @@ -158,7 +160,7 @@ inline uint64_t ChunkDistributor::deliverToAllStoredQu { if (isBlockingQueue) { - remainingQueues.emplace_back(queue); + fullQueuesAwaitingDelivery.emplace_back(queue); } else { @@ -171,43 +173,48 @@ inline uint64_t ChunkDistributor::deliverToAllStoredQu // busy waiting until every queue is served iox::detail::adaptive_wait adaptiveWait; - while (!remainingQueues.empty()) + while (!fullQueuesAwaitingDelivery.empty()) { adaptiveWait.wait(); { - // create intersection of current queues and remainingQueues + // create intersection of current queues and fullQueuesAwaitingDelivery // reason: it is possible that since the last iteration some subscriber have already unsubscribed // and without this intersection we would deliver to dead queues typename MemberType_t::LockGuard_t lock(*getMembers()); - typename ChunkDistributorDataType::QueueContainer_t queueIntersection(remainingQueues.size()); - auto greaterThan = [](RelativePointer& a, RelativePointer& b) -> bool { + QueueContainer remainingQueues; + using QueueContainerValue = typename QueueContainer::value_type; + auto greaterThan = [](QueueContainerValue& a, QueueContainerValue& b) -> bool { return reinterpret_cast(a.get()) > reinterpret_cast(b.get()); }; std::sort(getMembers()->m_queues.begin(), getMembers()->m_queues.end(), greaterThan); - std::sort(remainingQueues.begin(), remainingQueues.end(), greaterThan); - auto iter = std::set_intersection(getMembers()->m_queues.begin(), - getMembers()->m_queues.end(), - remainingQueues.begin(), - remainingQueues.end(), - queueIntersection.begin(), - greaterThan); - queueIntersection.resize(static_cast(iter - queueIntersection.begin())); - remainingQueues = queueIntersection; +#if (defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif + std::sort(fullQueuesAwaitingDelivery.begin(), fullQueuesAwaitingDelivery.end(), greaterThan); +#if (defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)) +#pragma GCC diagnostic pop +#endif + + std::set_intersection(getMembers()->m_queues.begin(), + getMembers()->m_queues.end(), + fullQueuesAwaitingDelivery.begin(), + fullQueuesAwaitingDelivery.end(), + std::back_inserter(remainingQueues), + greaterThan); + fullQueuesAwaitingDelivery.clear(); // deliver to remaining queues - for (uint64_t i = remainingQueues.size() - 1U; !remainingQueues.empty(); --i) + for (auto& queue : remainingQueues) { - if (pushToQueue(remainingQueues[i].get(), chunk)) + if (pushToQueue(queue.get(), chunk)) { - remainingQueues.erase(remainingQueues.begin() + i); ++numberOfQueuesTheChunkWasDeliveredTo; } - - // don't move this up since the for loop counts downwards and the algorithm would break - if (i == 0U) + else { - break; + fullQueuesAwaitingDelivery.push_back(queue); } } } From d3266b283dd103a922a4091ad5dc32f1cd4ea540 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sun, 12 Nov 2023 14:29:14 +0100 Subject: [PATCH 5/6] iox-#2047 Fix 'stringop-overflow' warning in shm safe unmagenged chunk --- iceoryx_posh/source/mepoo/shm_safe_unmanaged_chunk.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/iceoryx_posh/source/mepoo/shm_safe_unmanaged_chunk.cpp b/iceoryx_posh/source/mepoo/shm_safe_unmanaged_chunk.cpp index ebad953c4d..69173df233 100644 --- a/iceoryx_posh/source/mepoo/shm_safe_unmanaged_chunk.cpp +++ b/iceoryx_posh/source/mepoo/shm_safe_unmanaged_chunk.cpp @@ -71,7 +71,14 @@ SharedChunk ShmSafeUnmanagedChunk::cloneToSharedChunk() noexcept } auto chunkMgmt = RelativePointer(m_chunkManagement.offset(), segment_id_t{m_chunkManagement.id()}); +#if (defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif chunkMgmt->m_referenceCounter.fetch_add(1U, std::memory_order_relaxed); +#if (defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)) +#pragma GCC diagnostic pop +#endif return SharedChunk(chunkMgmt.get()); } From 11b454d57c37576a30031db2b7c00ad9470022eb Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sun, 12 Nov 2023 14:32:55 +0100 Subject: [PATCH 6/6] iox-#2047 Use GCC on Arch Linux --- .cirrus.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.cirrus.yaml b/.cirrus.yaml index cd896d4982..7171c175e6 100644 --- a/.cirrus.yaml +++ b/.cirrus.yaml @@ -132,10 +132,6 @@ arch_linux_x64_build_task: folder: iox-tests-bin reupload_on_changes: true fingerprint_key: $CIRRUS_OS_archlinux_x64_test_binaries_cache - env: - # use clang on Arch Linux since GCC triggers some compiler warnings which abort the job - CC: clang - CXX: clang++ build_script: <<: *IOX_POSIX_CLEAN_BUILD_WITH_ADDITIONAL_USER populate_test_binary_folder_script: