span-lite icon indicating copy to clipboard operation
span-lite copied to clipboard

Inconsitent behaviors with C array and make_span return type

Open fmatthew5876 opened this issue 3 years ago • 1 comments

Hello, please see the following:

static_assert(std::is_same<decltype(make_span(std::declval<int[5]>())),span<const int>>::value, "make_span Broken");
static_assert(std::is_same<decltype(make_span(std::declval<int(&)[5]>())),span<int,5>>::value, "make_span Broken");
static_assert(std::is_same<decltype(make_span(std::declval<const int[5]>())),span<const int,5>>::value, "make_span Broken");
static_assert(std::is_same<decltype(make_span(std::declval<const int(&)[5]>())),span<const int,5>>::value, "make_span Broken");

The first case returns a span with dynamic extent, while the other 3 return a span with a fixed size extent.

While non-const rvalue reference to C arrays almost never appear anywhere, this is a minor inconsistency and looks like a bug?

fmatthew5876 avatar Aug 18 '20 20:08 fmatthew5876

Above code in Compiler explorer.

martinmoene avatar Oct 02 '21 07:10 martinmoene