id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 9440,Spurious compilation failures on GCC 4.7.2,Andrey Semashev,Ion Gaztañaga,"I have a large project which uses Boost.Intrusive containers and some components of Boost.Interprocess, which also rely on Boost.Intrusive. When built on Debian Wheezy with GCC 4.7.2 (the stock version from the distribution repository) I get compilation failures, such as: {{{ In file included from /usr/include/boost/intrusive/detail/utilities.hpp:17:0, from /usr/include/boost/intrusive/options.hpp:20, from /home/lastique/src/xcoder/trunk/src/pipeline/pipelineI.h:16, from /home/lastique/src/xcoder/trunk/src/pipeline/pipelineI.cpp:1: /usr/include/boost/intrusive/pointer_traits.hpp: In instantiation of ‘static T* boost::intrusive::pointer_traits::static_cast_from(U*) [with U = const void; T = boost::intrusive::bhtraits, (boost::intrusive::link_mode_type)2u, for_wrapper_info_lookup_by_token, 3u>; boost::intrusive::pointer_traits::pointer = boost::intrusive::bhtraits, (boost::intrusive::link_mode_type)2u, for_wrapper_info_lookup_by_token, 3u>*]’: /usr/include/boost/intrusive/detail/tree_node.hpp:168:94: required from ‘boost::intrusive::tree_iterator::const_real_value_traits_ptr boost::intrusive::tree_iterator::get_real_value_traits() const [with RealValueTraits = boost::intrusive::bhtraits, (boost::intrusive::link_mode_type)2u, for_wrapper_info_lookup_by_token, 3u>; bool IsConst = false; boost::intrusive::tree_iterator::const_real_value_traits_ptr = const boost::intrusive::bhtraits, (boost::intrusive::link_mode_type)2u, for_wrapper_info_lookup_by_token, 3u>*]’ /usr/include/boost/intrusive/detail/tree_node.hpp:118:70: required from ‘boost::intrusive::tree_iterator::tree_iterator(const boost::intrusive::tree_iterator&) [with RealValueTraits = boost::intrusive::bhtraits, (boost::intrusive::link_mode_type)2u, for_wrapper_info_lookup_by_token, 3u>; bool IsConst = false]’ /home/lastique/src/xcoder/trunk/src/pipeline/pipelineI.cpp:557:80: required from here /usr/include/boost/intrusive/pointer_traits.hpp:245:39: error: static_cast from type ‘const void*’ to type ‘boost::intrusive::pointer_traits, (boost::intrusive::link_mode_type)2u, for_wrapper_info_lookup_by_token, 3u>*>::pointer {aka boost::intrusive::bhtraits, (boost::intrusive::link_mode_type)2u, for_wrapper_info_lookup_by_token, 3u>*}’ casts away qualifiers }}} and {{{ In file included from /home/lastique/src/xcoder/trunk/src/workers/picture2video/picturecache-index.h:20:0, from /home/lastique/src/xcoder/trunk/src/workers/picture2video/picturecache-index.cpp:18: /usr/include/boost/intrusive/list.hpp: In instantiation of ‘boost::intrusive::list_impl::const_real_value_traits_ptr boost::intrusive::list_impl::real_value_traits_ptr() const [with ValueTraits = boost::intrusive::mhtraits > >, &picture_cache_index::cache_element::lru_list_hook>; SizeType = long unsigned int; bool ConstantTimeSize = true; boost::intrusive::list_impl::const_real_value_traits_ptr = boost::interprocess::offset_ptr > >, &picture_cache_index::cache_element::lru_list_hook>, long int, long unsigned int, 0ul>]’: /usr/include/boost/intrusive/list.hpp:1264:85: required from ‘boost::intrusive::list_impl::iterator boost::intrusive::list_impl::iterator_to(boost::intrusive::list_impl::reference) [with ValueTraits = boost::intrusive::mhtraits > >, &picture_cache_index::cache_element::lru_list_hook>; SizeType = long unsigned int; bool ConstantTimeSize = true; boost::intrusive::list_impl::iterator = boost::intrusive::list_iterator > >, &picture_cache_index::cache_element::lru_list_hook>, false>; typename boost::intrusive::detail::get_real_value_traits::type = boost::intrusive::mhtraits > >, &picture_cache_index::cache_element::lru_list_hook>; boost::intrusive::list_impl::reference = picture_cache_index::cache_element&]’ /home/lastique/src/xcoder/trunk/src/workers/picture2video/picturecache-index.cpp:235:31: required from here /usr/include/boost/intrusive/list.hpp:183:99: error: no matching function for call to ‘boost::intrusive::pointer_traits > >, &picture_cache_index::cache_element::lru_list_hook>, long int, long unsigned int, 0ul> >::pointer_to(const real_value_traits&)’ /usr/include/boost/intrusive/list.hpp:183:99: note: candidate is: In file included from /usr/include/boost/interprocess/allocators/allocator.hpp:21:0, from /home/lastique/src/xcoder/trunk/src/workers/picture2video/picturecache-index.cpp:12: /usr/include/boost/intrusive/pointer_traits.hpp:94:19: note: static boost::intrusive::pointer_traits::pointer boost::intrusive::pointer_traits::pointer_to(boost::intrusive::pointer_traits::reference) [with Ptr = boost::interprocess::offset_ptr > >, &picture_cache_index::cache_element::lru_list_hook>, long int, long unsigned int, 0ul>; boost::intrusive::pointer_traits::pointer = boost::interprocess::offset_ptr > >, &picture_cache_index::cache_element::lru_list_hook>, long int, long unsigned int, 0ul>; boost::intrusive::pointer_traits::reference = boost::intrusive::mhtraits > >, &picture_cache_index::cache_element::lru_list_hook>&] /usr/include/boost/intrusive/pointer_traits.hpp:94:19: note: no known conversion for argument 1 from ‘const real_value_traits {aka const boost::intrusive::mhtraits > >, &picture_cache_index::cache_element::lru_list_hook>}’ to ‘boost::intrusive::pointer_traits > >, &picture_cache_index::cache_element::lru_list_hook>, long int, long unsigned int, 0ul> >::reference {aka boost::intrusive::mhtraits > >, &picture_cache_index::cache_element::lru_list_hook>&}’ }}} To my understanding the problem is caused by a compiler bug, which only manifests itself under some unknown and specific conditions. I could not reproduce it with a small code sample, and the same project (with the same Boost 1.55) compiles without problems with GCC 4.4.5 and 4.8.1 on Debian Squeeze and Kubuntu 13.10, respectively. The problem is that the compiler sometimes instantiates pointer_traits with an incorrect pointer type, which is missing the const qualifier in the element type (i.e. pointer_traits instead of pointer_traits). It happens with both raw and smart pointers, as seen in the errors above. I don't know how it happens, the relevant code of Boost.Intrusive seem correct to me. I have prepared a patch that works around this problem for me. Basically, I replaced the instantiation of pointer_traits in the problematic places with calls to free functions that instantiate pointer_traits themselves. With this patch applied, the project compiles without errors. ",Bugs,closed,To Be Determined,intrusive,Boost 1.55.0,Problem,wontfix,,