New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC 8.1 warning: _concurrent_unordered_impl.h: memset clearing an object of non-trivial type #54

Closed
madscientist opened this Issue May 13, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@madscientist

madscientist commented May 13, 2018

Compiling TBB 2018_U3 with the newly-release GCC 8.1 gives this warning (sorry for the line length):

tbb/include/tbb/internal/_concurrent_unordered_impl.h:1481:24: error: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'tbb::interface5::internal::concurrent_unordered_base<tbb::interface5::concurrent_unordered_map_traits<long unsigned int, DataDescriptor, tbb::interface5::internal::hash_compare<long unsigned int, tbb::tbb_hash<long unsigned int>, std::equal_to<long unsigned int> >, tbb::tbb_allocator<std::pair<const long unsigned int, DataDescriptor> >, false> >::raw_iterator' {aka 'class tbb::interface5::internal::flist_iterator<tbb::interface5::internal::split_ordered_list<std::pair<const long unsigned int, DataDescriptor>, tbb::tbb_allocator<std::pair<const long unsigned int, DataDescriptor> > >, std::pair<const long unsigned int, DataDescriptor> >'};
    use assignment or value-initialization instead [-Werror=class-memaccess]
             std::memset(new_segment, 0, sz*sizeof(raw_iterator));
             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tbb/include/tbb/internal/_concurrent_unordered_impl.h:71:7: note: 'tbb::interface5::internal::concurrent_unordered_base<tbb::interface5::concurrent_unordered_map_traits<long unsigned int, DataDescriptor, tbb::interface5::internal::hash_compare<long unsigned int, tbb::tbb_hash<long unsigned int>, std::equal_to<long unsigned int> >, tbb::tbb_allocator<std::pair<const long unsigned int, DataDescriptor> >, false> >::raw_iterator' {aka 'class tbb::interface5::internal::flist_iterator<tbb::interface5::internal::split_ordered_list<std::pair<const long unsigned int, DataDescriptor>, tbb::tbb_allocator<std::pair<const long unsigned int, DataDescriptor> > >, std::pair<const long unsigned int, DataDescriptor> >'}
    declared here
 class flist_iterator : public std::iterator<std::forward_iterator_tag, Value>
       ^~~~~~~~~~~~~~

I patched it locally to resolve this with:

--- a/include/tbb/internal/_concurrent_unordered_impl.h 2018-05-13 13:05:19.888005000 -0400
+++ b/include/tbb/internal/_concurrent_unordered_impl.h 2018-05-13 13:30:31.724891533 -0400
@@ -1468,7 +1468,7 @@
         if (my_buckets[segment] == NULL) {
             size_type sz = segment_size(segment);
             raw_iterator * new_segment = my_allocator.allocate(sz);
-            std::memset(new_segment, 0, sz*sizeof(raw_iterator));
+            std::memset(static_cast<void*>(new_segment), 0, sz*sizeof(raw_iterator));
 
             if (my_buckets[segment].compare_and_swap( new_segment, NULL) != NULL)
                 my_allocator.deallocate(new_segment, sz);

Note there may be other similar errors I didn't check all the code.

@akukanov

This comment has been minimized.

akukanov commented Nov 22, 2018

Fixed in TBB 2019.

@tbbdev tbbdev closed this Nov 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment