diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp index 9e129f059e..3968fd6503 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp @@ -54,6 +54,14 @@ namespace cxx /// // otherwise the code will not compile /// using ThisType::ThisType; // this makes all constructors of NewType available for Index /// using ThisType::operator=; // put the assignment operators in scope +/// +/// // implement ctors and assignment operators when they are implemented by the base class +/// // this is necessary pro prevent warnings from specific compilers +/// Index() noexcept = default; +/// Index(const Index&) noexcept = default; +/// Index(Index&&) noexcept = default; +/// Index& operator=(const Index&) noexcept = default; +/// Index& operator=(Index&&) noexcept = default; /// }; /// /// Index a(123), c(456); // allowed since we are using the policy ConstructByValueCopy diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_newtype.cpp b/iceoryx_hoofs/test/moduletests/test_cxx_newtype.cpp index 0a8e8d5cb1..02b22cdb23 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_newtype.cpp +++ b/iceoryx_hoofs/test/moduletests/test_cxx_newtype.cpp @@ -30,6 +30,14 @@ struct Sut : public T { using T::T; using T::operator=; // bring all operator= into scope + + // implement ctors and assignment operators when they are implemented by the base class + // this is necessary pro prevent warnings from specific compilers + Sut() noexcept = default; + Sut(const Sut&) noexcept = default; + Sut(Sut&&) noexcept = default; + Sut& operator=(const Sut&) noexcept = default; + Sut& operator=(Sut&&) noexcept = default; }; static CompileTest compileTest(R"( @@ -89,19 +97,8 @@ TEST(NewType, CopyAssignableDoesCompile) Sut> a(491), b(492), c(423); - // Ignore false positive - // See: https://isocpp.org/wiki/faq/strange-inheritance#hiding-rule - -#if (__GNUC__ == 9 && (__GNUC_MINOR__ > 1 || (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ > 0))) - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-copy" b = a; -#pragma GCC diagnostic pop EXPECT_TRUE(a == b); -#else - // Test disabled. -#endif } TEST(NewType, MoveConstructableDoesCompile)