kokkos icon indicating copy to clipboard operation
kokkos copied to clipboard

Incorrect constraints on `View(const View<DT, Prop...> &rhs)`

Open nmm0 opened this issue 1 year ago • 1 comments

Describe the bug

Our constraints are too relaxed and allow incompatible view types (i.e. rank > 1 of construction between a LayoutLeft and LayoutRight view). The code won't actually compile as we static assert, but it means that std::constructible_v<dst_type,src_type> gives the incorrect result.

Please include the following for a minimal reproducer

  1. Compilers (with versions) all
  2. Kokkos release or commit used (i.e., the sha1 number) confirmed on current develop and 4.2

Reproducer: https://godbolt.org/z/3roWPjzsz

nmm0 avatar Apr 17 '24 17:04 nmm0

This was not a bug or mistake: it was a design choice to provide comprehensible error messages. The issue is that the trait is_constructible_v is misleading since it only takes into account constraints and not mandates. With C++20 error messages of constraints become much better thanks to concepts. My current proposal is to shift constructor mandates to constraints when we compile with C++20 mode, but leave them alone in C++17 mode.

crtrott avatar Apr 23 '24 13:04 crtrott