- edited description
Clarification about type narrowing
Issue #149
invalid
This line of code generated a compiler warning (below)
rput_strided<2>(&u[0][1], {sizeof(double),(cols+haloCol)*sizeof(double)}, ul, {sizeof(double), left_nbr_cols*sizeof(double)}, {1,(rows+haloRow)}, remote_cx::as_rpc([](int phase){
nCount[phase]++;
},phase) | operation_cx::as_promise(p) );
I'm not fond of shutting off casting around warnings unless I'm sure I'm OK I've also tried to perform the requisite type casting, but no go. Could I get some clarify please? The PG doesn't get into this level of detail. The code is in the upc++_optimized branch (belonging to Hadia) in the scott repo Hadia will give permission to those who don't already have it.
fillGhost-globalU-upcxx.cpp:49:47: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'std::__1::array<long, 2>::value_type' (aka 'long') in initializer list [-Wc++11-narrowing]
rput_strided<2>(&u[0][1], {sizeof(double),(cols+haloCol)*sizeof(double)}, ul, {sizeof(double), left_nbr_cols*sizeof(double)}, {1,(rows+haloRow)}, remote_cx::as_rpc([](int phase){
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fillGhost-globalU-upcxx.cpp:49:47: note: insert an explicit cast to silence this issue
rput_strided<2>(&u[0][1], {sizeof(double),(cols+haloCol)*sizeof(double)}, ul, {sizeof(double), left_nbr_cols*sizeof(double)}, {1,(rows+haloRow)}, remote_cx::as_rpc([](int phase){
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
static_cast<value_type>( )
Comments (3)
-
reporter -
- edited description
-
- changed status to invalid
Scott -
The problem is the stride arrays in the rput_strided overload you are using have element type
ptrdiff_t
:template<std::size_t Dim, typename T, /*goop*/> /*goop*/ rput_strided( T const *src_base, std::array<std::ptrdiff_t,Dim> const &src_strides, global_ptr<T> dest_base, std::array<std::ptrdiff_t,Dim> const &dest_strides, std::array<std::size_t,Dim> const &extents, /*goop*/);
sizeof(double)
has typesize_t
(unsigned long), so you need to cast toptrdiff_t
(signed long) to match the element type in the function declaration. - Log in to comment