Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step-75: use well-formed deleter #13747

Merged
merged 1 commit into from May 17, 2022
Merged

Conversation

tamiko
Copy link
Member

@tamiko tamiko commented May 17, 2022

LLVM/Clang's libc++ library version 13/14 got stricter by checking
requirements of the deleter, in particular, according to [1] a deleter
must pass the requirement __shared_ptr_deleter_ctor_reqs which is
defined as follows:

template <class _Dp, class _Pt, class = decltype(declval<_Dp>()(declval<_Pt>()))>
static true_type __well_formed_deleter_test(int);

template <class, class>
static false_type __well_formed_deleter_test(...);

template <class _Dp, class _Pt>
struct __well_formed_deleter : decltype(__well_formed_deleter_test<_Dp, _Pt>(0)) {};

template<class _Dp, class _Tp, class _Yp>
struct __shared_ptr_deleter_ctor_reqs
{
    static const bool value = __compatible_with<_Tp, _Yp>::value &&
                              is_move_constructible<_Dp>::value &&
                              __well_formed_deleter<_Dp, _Tp*>::value;
};

Unfortunately, our construct

coarse_grid_triangulations.emplace_back(
  const_cast<Triangulation<dim> *>(&(dof_handler.get_triangulation())),
  [](auto &) {});

does not pass this test. The issue is that the deleter takes a pointer,
not a reference which, so the lambda [](auto &){} does not pass above
__shared_ptr_deleter_ctor_reqs.

While at it, remove the const cast: coarse_grid_triangulations is
declared as a vector holding a shared_ptr<const Triangulation<dim>>,
thus we should simply take the address and not convert to a non-const
object.

Fixes
https://cdash.dealii.43-1.org/viewBuildError.php?buildid=1614
https://cdash.dealii.43-1.org/viewBuildError.php?buildid=1613

[1] https://github.com/llvm/llvm-project/blob/main/libcxx/include/__memory/shared_ptr.h

Closes #13613

@tamiko tamiko requested a review from marcfehling May 17, 2022 04:38
@tamiko tamiko added this to the Release 9.4 milestone May 17, 2022
@tamiko
Copy link
Member Author

tamiko commented May 17, 2022

/rebuild

Copy link
Member

@marcfehling marcfehling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fix #13613, right?

@tamiko
Copy link
Member Author

tamiko commented May 17, 2022

@marcfehling yes. I wasn't aware of the issue.

examples/step-75/step-75.cc Outdated Show resolved Hide resolved
LLVM/Clang's libc++ library version 13/14 got stricter by checking
requirements of the deleter, in particular, according to [1] a deleter
must pass the requirement `__shared_ptr_deleter_ctor_reqs` which is
defined as follows:
```
template <class _Dp, class _Pt, class = decltype(declval<_Dp>()(declval<_Pt>()))>
static true_type __well_formed_deleter_test(int);

template <class, class>
static false_type __well_formed_deleter_test(...);

template <class _Dp, class _Pt>
struct __well_formed_deleter : decltype(__well_formed_deleter_test<_Dp, _Pt>(0)) {};

template<class _Dp, class _Tp, class _Yp>
struct __shared_ptr_deleter_ctor_reqs
{
    static const bool value = __compatible_with<_Tp, _Yp>::value &&
                              is_move_constructible<_Dp>::value &&
                              __well_formed_deleter<_Dp, _Tp*>::value;
};
```
Unfortunately, our construct
```
coarse_grid_triangulations.emplace_back(
  const_cast<Triangulation<dim> *>(&(dof_handler.get_triangulation())),
  [](auto &) {});
```
does not pass this test. The issue is that the deleter takes a pointer,
not a reference which, so the lambda `[](auto &){}` does not pass above
`__shared_ptr_deleter_ctor_reqs`.

While at it, remove the const cast: `coarse_grid_triangulations` is
declared as a vector holding a `shared_ptr<const Triangulation<dim>>`,
thus we should simply take the address and not convert to a non-const
object.

[1] https://github.com/llvm/llvm-project/blob/main/libcxx/include/__memory/shared_ptr.h
@peterrum peterrum merged commit af0efbf into dealii:master May 17, 2022
@tamiko tamiko deleted the fix_step_75_emplace branch November 30, 2022 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compilation issue step-75 on ARM clang 13
4 participants