diff --git a/include/etl/span.h b/include/etl/span.h index 8f57148f..5d03632a 100644 --- a/include/etl/span.h +++ b/include/etl/span.h @@ -1303,7 +1303,7 @@ namespace etl span as_bytes(span s) ETL_NOEXCEPT { - return span(reinterpret_cast(s.data()), s.size_bytes()); + return span(reinterpret_cast(s.data()), s.size_bytes()); } //************************************************************************* diff --git a/test/test_span_dynamic_extent.cpp b/test/test_span_dynamic_extent.cpp index 7fc1c8c0..586eadcb 100644 --- a/test/test_span_dynamic_extent.cpp +++ b/test/test_span_dynamic_extent.cpp @@ -1325,8 +1325,9 @@ namespace TEST(test_convert_span_any_to_span_byte) { float data[2]{3.141592f, 2.71828f }; + const float const_data[2]{3.141592f, 2.71828f }; - auto const const_bytes = etl::as_bytes(etl::span{data}); + auto const const_bytes = etl::as_bytes(etl::span{const_data}); auto const writable_bytes = etl::as_writable_bytes(etl::span{data}); CHECK_EQUAL(const_bytes.size(), sizeof(data)); diff --git a/test/test_span_fixed_extent.cpp b/test/test_span_fixed_extent.cpp index 137bd9b8..a1825c2c 100644 --- a/test/test_span_fixed_extent.cpp +++ b/test/test_span_fixed_extent.cpp @@ -1163,12 +1163,13 @@ namespace TEST(test_convert_span_any_to_span_byte) { float data[2]{3.141592f, 2.71828f}; + const float const_data[2]{3.141592f, 2.71828f}; #if ETL_USING_CPP17 - auto const const_bytes = etl::as_bytes(etl::span{ data }); + auto const const_bytes = etl::as_bytes(etl::span{ const_data }); auto const writable_bytes = etl::as_writable_bytes(etl::span{ data }); #else - auto const const_bytes = etl::as_bytes(etl::span(data)); + auto const const_bytes = etl::as_bytes(etl::span(const_data)); auto const writable_bytes = etl::as_writable_bytes(etl::span(data)); #endif