Skip to content

Commit

Permalink
iox-#2011 Silence some warnings when building with GCC 13.
Browse files Browse the repository at this point in the history
GCC 13 (which is in Ubuntu 24.04) introduced a number of
false positive warnings when using -Warray-bounds and -Wstring-op; see:

* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114758
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111118
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110807
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110498

In my testing, these only show up when building with optimizations,
i.e. CMAKE_BUILD_TYPE=RelWithDebInfo.

This commit silences those warnings across the two functions
that cause the problem, and make the build completely clean.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
  • Loading branch information
clalancette committed Jun 3, 2024
1 parent 6d357df commit 434ee45
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

**Refactoring:**

- Silence warnings when building with GCC 13 [\#2011](https://github.com/eclipse-iceoryx/iceoryx/issues/2011)

**New API features:**

**API Breaking Changes:**
Expand Down
10 changes: 10 additions & 0 deletions iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_queue.inl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IOX_HOOFS_CXX_VARIANT_QUEUE_INL
#define IOX_HOOFS_CXX_VARIANT_QUEUE_INL

#include "iceoryx_hoofs/cxx/variant_queue.hpp"
#include "iceoryx_hoofs/error_handling/error_handling.hpp"

namespace iox
Expand Down Expand Up @@ -49,6 +50,11 @@ inline VariantQueue<ValueType, Capacity>::VariantQueue(const VariantQueueTypes t
}
}

#if (defined(__GNUC__) && __GNUC__ >= 13 && !defined(__clang__))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif

template <typename ValueType, uint64_t Capacity>
optional<ValueType> VariantQueue<ValueType, Capacity>::push(const ValueType& value) noexcept
{
Expand Down Expand Up @@ -90,6 +96,10 @@ optional<ValueType> VariantQueue<ValueType, Capacity>::push(const ValueType& val
return cxx::nullopt;
}

#if (defined(__GNUC__) && __GNUC__ >= 13 && !defined(__clang__))
#pragma GCC diagnostic pop
#endif

template <typename ValueType, uint64_t Capacity>
inline optional<ValueType> VariantQueue<ValueType, Capacity>::pop() noexcept
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ inline bool ChunkDistributor<ChunkDistributorDataType>::hasStoredQueues() const
return !getMembers()->m_queues.empty();
}

#if (defined(__GNUC__) && __GNUC__ >= 13 && !defined(__clang__))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif

template <typename ChunkDistributorDataType>
inline uint64_t ChunkDistributor<ChunkDistributorDataType>::deliverToAllStoredQueues(mepoo::SharedChunk chunk) noexcept
{
Expand Down Expand Up @@ -209,6 +214,10 @@ inline uint64_t ChunkDistributor<ChunkDistributorDataType>::deliverToAllStoredQu
return numberOfQueuesTheChunkWasDeliveredTo;
}

#if (defined(__GNUC__) && __GNUC__ >= 13 && !defined(__clang__))
#pragma GCC diagnostic pop
#endif

template <typename ChunkDistributorDataType>
inline bool ChunkDistributor<ChunkDistributorDataType>::pushToQueue(cxx::not_null<ChunkQueueData_t* const> queue,
mepoo::SharedChunk chunk) noexcept
Expand Down

0 comments on commit 434ee45

Please sign in to comment.