diff -Nru dune-functions-2.7.0/debian/changelog dune-functions-2.7.1/debian/changelog --- dune-functions-2.7.0/debian/changelog 2020-07-17 16:52:48.000000000 +0000 +++ dune-functions-2.7.1/debian/changelog 2021-01-13 09:53:16.000000000 +0000 @@ -1,8 +1,14 @@ -dune-functions (2.7.0-2build1) groovy; urgency=medium +dune-functions (2.7.1-2) unstable; urgency=medium - * Rebuild against new dune 2.7. + * Upload to unstable. - -- Gianfranco Costamagna Fri, 17 Jul 2020 18:52:48 +0200 + -- Ansgar Wed, 13 Jan 2021 10:53:16 +0100 + +dune-functions (2.7.1-1) experimental; urgency=medium + + * New upstream release. + + -- Lisa Julia Nebel Thu, 07 Jan 2021 10:49:29 +0100 dune-functions (2.7.0-2) unstable; urgency=medium diff -Nru dune-functions-2.7.0/debian/control dune-functions-2.7.1/debian/control --- dune-functions-2.7.0/debian/control 2020-05-30 10:43:14.000000000 +0000 +++ dune-functions-2.7.1/debian/control 2021-01-07 14:00:24.000000000 +0000 @@ -9,10 +9,10 @@ Homepage: https://www.dune-project.org/ Build-Depends: debhelper-compat (= 13), cmake, gfortran, mpi-default-bin, mpi-default-dev, pkg-config, python3, - libdune-localfunctions-dev (>= 2.7.0), - libdune-grid-dev (>= 2.7.0), - libdune-istl-dev (>= 2.7.0), - libdune-typetree-dev (>= 2.7.0) + libdune-localfunctions-dev (>= 2.7.1), + libdune-grid-dev (>= 2.7.1), + libdune-istl-dev (>= 2.7.1), + libdune-typetree-dev (>= 2.7.1) Build-Depends-Indep: doxygen, ghostscript, graphviz, imagemagick, texlive-latex-extra, texlive-latex-recommended, texlive-pictures Rules-Requires-Root: no @@ -20,9 +20,9 @@ Section: libdevel Architecture: all Depends: ${misc:Depends}, - libdune-localfunctions-dev (>= 2.7.0), - libdune-grid-dev (>= 2.7.0), - libdune-typetree-dev (>= 2.7.0) + libdune-localfunctions-dev (>= 2.7.1), + libdune-grid-dev (>= 2.7.1), + libdune-typetree-dev (>= 2.7.1) Suggests: libdune-functions-doc (= ${source:Version}) Description: toolbox for solving PDEs -- interface for functions (development files) DUNE, the Distributed and Unified Numerics Environment is a modular toolbox diff -Nru dune-functions-2.7.0/dune/functions/common/polymorphicsmallobject.hh dune-functions-2.7.1/dune/functions/common/polymorphicsmallobject.hh --- dune-functions-2.7.0/dune/functions/common/polymorphicsmallobject.hh 2020-01-12 13:35:54.000000000 +0000 +++ dune-functions-2.7.1/dune/functions/common/polymorphicsmallobject.hh 2020-10-29 19:47:28.000000000 +0000 @@ -4,6 +4,7 @@ #define DUNE_FUNCTIONS_COMMON_POLYMORPHICSMALLOBJECT_HH #include +#include #include #include @@ -33,11 +34,11 @@ * that Base has a virtual destructor. * * In order to make the copy constructor work for polymorphic types, - * Base must provide virtual methods clone() and clone(void*). The former should return - * a pointer to a dynamically allocated clone, while the latter - * should call the appropriate placement-new with the passed pointer. + * Base must provide virtual methods `Base* clone()` and `Base* clone(void*)`. + * The former should return a pointer to a dynamically allocated clone, while + * the latter should call the appropriate placement-new with the passed pointer. * - * Similarly the polymorphic type has to implement a virtual move(void*) + * Similarly the polymorphic type has to implement a virtual `Base* move(void*)` * method. * This should call placement-new and can std::move all the * data but leave the object in a valid and probably unusable state. @@ -55,16 +56,18 @@ /** * \brief Construct from object * - * \tparam Derived Type of object to be stored, should be derived from Base + * \tparam Derived Type of object to be stored, must be derived from Base * \param derived Object to be stored */ - template + template>>::value, int>::type = 0> PolymorphicSmallObject(Derived&& derived) { using namespace Dune::Hybrid; - auto useBuffer = Dune::Std::bool_constant<(sizeof(Derived)(); + auto useBuffer = Dune::Std::bool_constant<(sizeof(Derived) <= bufferSize)>(); ifElse(useBuffer, [&](auto id) { - p_ = new (buffer_) Derived(std::forward(derived)); + p_ = new (&buffer_) Derived(std::forward(derived)); }, [&](auto id) { p_ = new Derived(std::forward(derived)); }); @@ -91,8 +94,11 @@ //! Copy assignment from other PolymorphicSmallObject PolymorphicSmallObject& operator=(const PolymorphicSmallObject& other) { - destroyWrappedObject(); - copyToWrappedObject(other); + if (&other!=this) + { + destroyWrappedObject(); + copyToWrappedObject(other); + } return *this; } @@ -144,12 +150,12 @@ void moveToWrappedObject(PolymorphicSmallObject&& other) { if (other.bufferUsed()) - p_ = other.p_->move(buffer_); + p_ = other.p_->move(&buffer_); else { // We don't need to check for &other_!=this, because you can't // have an rvalue to *this and call it's assignment/constructor - // at the same time. (Despite trying to shot yourself in the foot + // at the same time. (Despite trying to shoot yourself in the foot // with std::move explicitly.) // Take ownership of allocated object @@ -162,16 +168,13 @@ void copyToWrappedObject(const PolymorphicSmallObject& other) { - if (&other!=this) - { - if (other.bufferUsed()) - p_ = other.p_->clone(buffer_); - else - p_ = other.p_->clone(); - } + if (other.bufferUsed()) + p_ = other.p_->clone(&buffer_); + else + p_ = other.p_->clone(); } - alignas(Base) char buffer_[bufferSize]; + std::aligned_storage_t buffer_; Base* p_; }; diff -Nru dune-functions-2.7.0/dune/functions/common/test/CMakeLists.txt dune-functions-2.7.1/dune/functions/common/test/CMakeLists.txt --- dune-functions-2.7.0/dune/functions/common/test/CMakeLists.txt 2020-01-12 13:35:54.000000000 +0000 +++ dune-functions-2.7.1/dune/functions/common/test/CMakeLists.txt 2020-10-29 19:47:28.000000000 +0000 @@ -1,3 +1,4 @@ # tests that should build and run successfully dune_add_test(SOURCES differentiablefunctiontest.cc) +dune_add_test(SOURCES polymorphicsmallobjecttest.cc) diff -Nru dune-functions-2.7.0/dune/functions/common/test/polymorphicsmallobjecttest.cc dune-functions-2.7.1/dune/functions/common/test/polymorphicsmallobjecttest.cc --- dune-functions-2.7.0/dune/functions/common/test/polymorphicsmallobjecttest.cc 1970-01-01 00:00:00.000000000 +0000 +++ dune-functions-2.7.1/dune/functions/common/test/polymorphicsmallobjecttest.cc 2020-10-29 19:47:28.000000000 +0000 @@ -0,0 +1,106 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#include + +#include +#include +#include + +#include +#include +#include +#include + +class Base +{ +public: + virtual ~Base() = default; + virtual Base* clone() = 0; + virtual Base* clone(void*) = 0; + virtual Base* move(void*) = 0; + virtual int foo() = 0; + virtual bool checkMemberAlignment() = 0; +}; + +class Derived + : public virtual Base +{ + long double dummy_; + int i_; +public: + virtual ~Derived() = default; + Derived(int i = 0) : i_(i) {} + Base* clone() final { return new Derived{i_}; } + Base* clone(void* ptr) final { return new (ptr) Derived{this->i_}; } + Base* move(void* ptr) final { return new (ptr) Derived{std::move(this->i_)}; } + int foo() final { return i_; } + bool checkMemberAlignment() final { + return (reinterpret_cast(&dummy_) % alignof(long double)) == 0; + } +}; + +bool checkTrue(bool value, std::string error) +{ + if (not(value)) + std::cout << "TEST FAILURE:" << error << std::endl; + return value; +} + +template +bool test() +{ + bool success = true; + + std::array v{Derived{2}, Derived{2}}; + success &= checkTrue(v[0].get().checkMemberAlignment(), "Invalid alignment of member!"); + success &= checkTrue(v[1].get().checkMemberAlignment(), "Invalid alignment of member!"); + + Obj obj(Derived{2}); + success &= checkTrue(obj.get().foo() == 2, "Invalid state using constructor with Derived argument!"); + + Obj objCopy(obj); + success &= checkTrue(objCopy.get().foo() == 2, "Invalid state using copy constructor!"); + + Obj objMove(std::move(objCopy)); + success &= checkTrue(objMove.get().foo() == 2, "Invalid state using move constructor!"); + + Obj objCopyAssign = obj; + success &= checkTrue(objCopyAssign.get().foo() == 2, "Invalid state using copy assignment!"); + + Obj objMoveAssign = std::move(objCopyAssign); + success &= checkTrue(objMoveAssign.get().foo() == 2, "Invalid state using move assignment!"); + + obj = obj; + success &= checkTrue(obj.get().foo() == 2, "Invalid state using self assignment!"); + + return success; +} + +int main ( int argc, char **argv ) +try +{ + Dune::MPIHelper::instance(argc, argv); + bool passed = true; + + std::cout << "Testing PolymorphicSmallObject with no buffer" << std::endl; + passed &= test>(); + + std::cout << "Testing PolymorphicSmallObject with buffer" << std::endl; + constexpr std::size_t OBJSIZE = sizeof(Derived); + passed &= test>(); + + if (passed) + std::cout << "All tests passed" << std::endl; + + return passed ? 0: 1; +} +catch( Dune::Exception &e ) +{ + std::cerr << "Dune reported error: " << e << std::endl; + return 1; +} +catch(...) +{ + std::cerr << "Unknown exception thrown!" << std::endl; + return 1; +} diff -Nru dune-functions-2.7.0/dune.module dune-functions-2.7.1/dune.module --- dune-functions-2.7.0/dune.module 2020-01-12 13:35:54.000000000 +0000 +++ dune-functions-2.7.1/dune.module 2020-10-29 19:47:28.000000000 +0000 @@ -1,7 +1,7 @@ # Dune module information file Module: dune-functions -Version: 2.7.0 +Version: 2.7.1 Maintainer: dune-functions@lists.dune-project.org Depends: dune-localfunctions (>= 2.7) dune-grid (>= 2.7) dune-istl (>= 2.7) dune-typetree (>= 2.7) Whitespace-Hook: Yes diff -Nru dune-functions-2.7.0/.gitlab-ci.yml dune-functions-2.7.1/.gitlab-ci.yml --- dune-functions-2.7.0/.gitlab-ci.yml 2020-01-12 13:35:54.000000000 +0000 +++ dune-functions-2.7.1/.gitlab-ci.yml 2020-10-29 19:47:28.000000000 +0000 @@ -1,7 +1,11 @@ --- include: - - "https://gitlab.dune-project.org/core/ci-config/raw/master/config/common/master.yml" - - "https://gitlab.dune-project.org/core/ci-config/raw/master/jobs/common/master.yml" + - project: 'core/ci-config' + ref: master + file: 'config/common/releases/2.7.yml' + - project: 'core/ci-config' + ref: master + file: 'jobs/common/releases/2.7.yml' before_script: - . /duneci/bin/duneci-init-job