Skip to content

Commit

Permalink
Merge pull request #80 from sslattery/fix_zero_size_slice
Browse files Browse the repository at this point in the history
Fixing slice construction for uninitialized AoSoAs
  • Loading branch information
dalg24 authored Mar 12, 2019
2 parents 6e1289b + e2507aa commit d1cbe48
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/src/Cabana_AoSoA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,18 @@ class AoSoA
0 == sizeof(soa_type) % sizeof(member_value_type<M>),
"Slice stride cannot be calculated for misaligned memory!" );

member_pointer_type<M> data_ptr =
( _data.size() > 0 )
? static_cast<member_pointer_type<M> >(_data(0).template ptr<M>())
: nullptr;

return
Slice<member_data_type<M>,
memory_space,
DefaultAccessMemory,
vector_length,
sizeof(soa_type) / sizeof(member_value_type<M>)>
( static_cast<member_pointer_type<M> >(_data(0).template ptr<M>()),
_size,
_num_soa );
sizeof(soa_type) / sizeof(member_value_type<M>)>(
data_ptr, _size, _num_soa );
}

/*!
Expand Down

0 comments on commit d1cbe48

Please sign in to comment.