diff --git a/sycl/include/sycl/types.hpp b/sycl/include/sycl/types.hpp index ae1b2655d7320..2a59173c684c7 100644 --- a/sycl/include/sycl/types.hpp +++ b/sycl/include/sycl/types.hpp @@ -916,7 +916,7 @@ template class vec { __SYCL2020_DEPRECATED( "get_size() is deprecated, please use byte_size() instead") static constexpr size_t get_size() { return byte_size(); } - static constexpr size_t byte_size() { return sizeof(m_Data); } + static constexpr size_t byte_size() noexcept { return sizeof(m_Data); } template diff --git a/sycl/test-e2e/Basic/vector_operators.cpp b/sycl/test-e2e/Basic/vector_operators.cpp index b64f9adf93d41..d149af28de62b 100644 --- a/sycl/test-e2e/Basic/vector_operators.cpp +++ b/sycl/test-e2e/Basic/vector_operators.cpp @@ -35,6 +35,7 @@ template void check_vector_size() { constexpr auto length = (N == 3 ? 4 : N); assert(Vec.size() == N); assert(Vec.byte_size() == sizeof(T) * length); + static_assert(noexcept(Vec.byte_size())); } int main() {