Boost logo

Boost Users :

Subject: [Boost-users] [type_traits] type_with_alignment<64> on gcc
From: Ioannis Papadopoulos (ipapadop_at_[hidden])
Date: 2012-01-04 02:26:57


Hi,

Is there any particular reason that type_with_alignment does not support
alignment more than 32 on gcc?

I am trying to create an unordered_map of objects that are aligned to
cache line size (64bytes) and it fails in type_with_alignment. This
small example shows it:

#include <boost/tr1/unordered_map.hpp>

struct __attribute__((aligned(64)) A { int i; };

int main()
{
  std::tr1::unordered_map<int, A> umap;
  umap[0] = A();
  return 0;
}

In file included from
/usr/local/boost/boost_1.48/include/boost/aligned_storage.hpp:21:0,
                 from
/usr/local/boost/boost_1.48/include/boost/type_traits/aligned_storage.hpp:11,
                 from
/usr/local/boost/boost_1.48/include/boost/unordered/detail/buckets.hpp:17,
                 from
/usr/local/boost/boost_1.48/include/boost/unordered/detail/table.hpp:10,
                 from
/usr/local/boost/boost_1.48/include/boost/unordered/detail/equivalent.hpp:14,
                 from
/usr/local/boost/boost_1.48/include/boost/unordered/unordered_map.hpp:18,
                 from
/usr/local/boost/boost_1.48/include/boost/unordered_map.hpp:16,
                 from
/usr/local/boost/boost_1.48/include/boost/tr1/unordered_map.hpp:21,
                 from test.cc:1:
/usr/local/boost/boost_1.48/include/boost/type_traits/type_with_alignment.hpp:
In instantiation of ¡boost::detail::type_with_alignment_imp<64ul>¢:
/usr/local/boost/boost_1.48/include/boost/type_traits/type_with_alignment.hpp:216:7:
  instantiated from ¡boost::type_with_alignment<64ul>¢
/usr/local/boost/boost_1.48/include/boost/mpl/eval_if.hpp:60:31:
instantiated from ¡boost::mpl::eval_if_c<false,
boost::mpl::identity<boost::detail::max_align>,
boost::type_with_alignment<64ul> >¢
/usr/local/boost/boost_1.48/include/boost/aligned_storage.hpp:55:21:
instantiated from
¡boost::detail::aligned_storage::aligned_storage_imp<128ul, 64ul>::data_t¢
/usr/local/boost/boost_1.48/include/boost/aligned_storage.hpp:56:7:
instantiated from
¡boost::detail::aligned_storage::aligned_storage_imp<128ul, 64ul>¢
/usr/local/boost/boost_1.48/include/boost/aligned_storage.hpp:73:7:
instantiated from ¡boost::aligned_storage<128ul, 64ul>¢
/usr/local/boost/boost_1.48/include/boost/unordered/detail/table.hpp:281:59:
  instantiated from
¡boost::unordered::detail::value_base<std::pair<const int, A> >¢
/usr/local/boost/boost_1.48/include/boost/unordered/detail/unique.hpp:47:12:
  instantiated from ¡boost::unordered::detail::ptr_node<std::pair<const
int, A> >¢
/usr/local/boost/boost_1.48/include/boost/unordered/detail/unique.hpp:332:40:
  instantiated from
¡boost::unordered::detail::table_impl<Types>::value_type&
boost::unordered::detail::table_impl<Types>::operator[](const key_type&)
[with Types =
boost::unordered::detail::map<std::allocator<std::pair<const int, A> >,
int, boost::hash<int>, std::equal_to<int> >,
boost::unordered::detail::table_impl<Types>::value_type =
std::pair<const int, A>,
boost::unordered::detail::table_impl<Types>::key_type = int]¢
/usr/local/boost/boost_1.48/include/boost/unordered/unordered_map.hpp:1007:26:
  instantiated from ¡boost::unordered::unordered_map<K, T, H, P,
A>::mapped_type& boost::unordered::unordered_map<K, T, H, P,
A>::operator[](const key_type&) [with K = int, T = A, H =
boost::hash<int>, P = std::equal_to<int>, A =
std::allocator<std::pair<const int, A> >,
boost::unordered::unordered_map<K, T, H, P, A>::mapped_type = A,
boost::unordered::unordered_map<K, T, H, P, A>::key_type = int]¢
test.cc:11:9: instantiated from here
/usr/local/boost/boost_1.48/include/boost/type_traits/type_with_alignment.hpp:206:1:
error: invalid application of ¡sizeof¢ to incomplete type
¡boost::STATIC_ASSERTION_FAILURE<false>¢
/usr/local/boost/boost_1.48/include/boost/type_traits/type_with_alignment.hpp:207:1:
error: invalid application of ¡sizeof¢ to incomplete type
¡boost::STATIC_ASSERTION_FAILURE<false>¢

Is there any easy way to avoid this problem?

Thanks


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net