Opened 9 years ago
Closed 8 years ago
#9440 closed Bugs (wontfix)
Spurious compilation failures on GCC 4.7.2
Reported by: | Andrey Semashev | Owned by: | Ion Gaztañaga |
---|---|---|---|
Milestone: | To Be Determined | Component: | intrusive |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
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<T*>::static_cast_from(U*) [with U = const void; T = boost::intrusive::bhtraits<Pipeline_i::wrapper_info, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)2u, for_wrapper_info_lookup_by_token, 3u>; boost::intrusive::pointer_traits<T*>::pointer = boost::intrusive::bhtraits<Pipeline_i::wrapper_info, boost::intrusive::rbtree_node_traits<void*, true>, (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<RealValueTraits, IsConst>::const_real_value_traits_ptr boost::intrusive::tree_iterator<RealValueTraits, IsConst>::get_real_value_traits() const [with RealValueTraits = boost::intrusive::bhtraits<Pipeline_i::wrapper_info, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)2u, for_wrapper_info_lookup_by_token, 3u>; bool IsConst = false; boost::intrusive::tree_iterator<RealValueTraits, IsConst>::const_real_value_traits_ptr = const boost::intrusive::bhtraits<Pipeline_i::wrapper_info, boost::intrusive::rbtree_node_traits<void*, true>, (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<RealValueTraits, IsConst>::tree_iterator(const boost::intrusive::tree_iterator<RealValueTraits, false>&) [with RealValueTraits = boost::intrusive::bhtraits<Pipeline_i::wrapper_info, boost::intrusive::rbtree_node_traits<void*, true>, (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::bhtraits<Pipeline_i::wrapper_info, boost::intrusive::rbtree_node_traits<void*, true>, (boost::intrusive::link_mode_type)2u, for_wrapper_info_lookup_by_token, 3u>*>::pointer {aka boost::intrusive::bhtraits<Pipeline_i::wrapper_info, boost::intrusive::rbtree_node_traits<void*, true>, (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<ValueTraits, SizeType, ConstantTimeSize>::const_real_value_traits_ptr boost::intrusive::list_impl<ValueTraits, SizeType, ConstantTimeSize>::real_value_traits_ptr() const [with ValueTraits = boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &picture_cache_index::cache_element::lru_list_hook>; SizeType = long unsigned int; bool ConstantTimeSize = true; boost::intrusive::list_impl<ValueTraits, SizeType, ConstantTimeSize>::const_real_value_traits_ptr = boost::interprocess::offset_ptr<const boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &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<ValueTraits, SizeType, ConstantTimeSize>::iterator boost::intrusive::list_impl<ValueTraits, SizeType, ConstantTimeSize>::iterator_to(boost::intrusive::list_impl<ValueTraits, SizeType, ConstantTimeSize>::reference) [with ValueTraits = boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &picture_cache_index::cache_element::lru_list_hook>; SizeType = long unsigned int; bool ConstantTimeSize = true; boost::intrusive::list_impl<ValueTraits, SizeType, ConstantTimeSize>::iterator = boost::intrusive::list_iterator<boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &picture_cache_index::cache_element::lru_list_hook>, false>; typename boost::intrusive::detail::get_real_value_traits<ValueTraits>::type = boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &picture_cache_index::cache_element::lru_list_hook>; boost::intrusive::list_impl<ValueTraits, SizeType, ConstantTimeSize>::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<boost::interprocess::offset_ptr<boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &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<Ptr>::pointer boost::intrusive::pointer_traits<Ptr>::pointer_to(boost::intrusive::pointer_traits<Ptr>::reference) [with Ptr = boost::interprocess::offset_ptr<boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &picture_cache_index::cache_element::lru_list_hook>, long int, long unsigned int, 0ul>; boost::intrusive::pointer_traits<Ptr>::pointer = boost::interprocess::offset_ptr<boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &picture_cache_index::cache_element::lru_list_hook>, long int, long unsigned int, 0ul>; boost::intrusive::pointer_traits<Ptr>::reference = boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &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, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &picture_cache_index::cache_element::lru_list_hook>}’ to ‘boost::intrusive::pointer_traits<boost::interprocess::offset_ptr<boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &picture_cache_index::cache_element::lru_list_hook>, long int, long unsigned int, 0ul> >::reference {aka boost::intrusive::mhtraits<picture_cache_index::cache_element, boost::intrusive::list_member_hook<boost::intrusive::void_pointer<boost::interprocess::offset_ptr<void> > >, &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<foo*> instead of pointer_traits<const foo*>). 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.
Attachments (1)
Change History (6)
by , 9 years ago
Attachment: | intrusive_gcc47_drops_qualifiers.patch added |
---|
comment:1 by , 9 years ago
pointer_to is used more than 100 times the library and we are not sure if this would fix the problem as the compiler bug might appear in other places. Could you test if this problem is also present with the latest GCC 4.7 (4.7.3)?
comment:2 by , 9 years ago
Updating to GCC 4.7.3 is rather problematic since the Debian Wheezy machine is actually a corporate server which I cannot upgrade. I could try creating a virtual machine with Debian Jessie which has 4.7.3, but that would take a lot of time, I can't tell when I'm able to do it.
comment:4 by , 9 years ago
confirmed on ubuntu 4.7.2 . same problem about not being able to update/change gcc
comment:5 by , 8 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Sorry for not being able to dedicate resources to this. Closing as wontfix.
The patch works around compilation failures with GCC 4.7.2.