[Boost-bugs] [Boost C++ Libraries] #9440: Spurious compilation failures on GCC 4.7.2

Subject: [Boost-bugs] [Boost C++ Libraries] #9440: Spurious compilation failures on GCC 4.7.2
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-11-27 12:36:49


#9440: Spurious compilation failures on GCC 4.7.2
------------------------------+------------------------
 Reporter: andysem | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: intrusive
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
------------------------------+------------------------
 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9440>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:14 UTC