Opened 15 years ago

Closed 12 years ago

#1610 closed Bugs (wontfix)

[MSVC/STLport] [tree/common.hpp] Standard library requirements violation(incomplete type as vector parameter)

Reported by: archimed7592+svc@… Owned by: Joel de Guzman
Milestone: Boost 1.36.0 Component: spirit
Version: Boost 1.34.1 Severity: Problem
Keywords: stlport Cc:

Description

boost/spirit/tree/common.hpp

template <typename T>
struct tree_node
{
    typedef T parse_node_t;
    
#if !defined(BOOST_SPIRIT_USE_BOOST_ALLOCATOR_FOR_TREES)
    typedef std::allocator<tree_node<T> > allocator_type;
#elif !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES)
    typedef boost::pool_allocator<tree_node<T> > allocator_type;
#else
    typedef boost::fast_pool_allocator<tree_node<T> > allocator_type;
#endif

#if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES)
    typedef std::vector<tree_node<T>, allocator_type> children_t;
#else
    typedef std::list<tree_node<T>, allocator_type> children_t;
#endif  // BOOST_SPIRIT_USE_LIST_FOR_TREES

    typedef typename children_t::iterator tree_iterator;
    typedef typename children_t::const_iterator const_tree_iterator;

The problem: children_t::blablabla triggers implicit instantiation of children_t, which have tree_node as its template parameter i.e. incomplete type. This code violates 17.4.3.6/2

In particular, the effects are undefined in the following cases:
...
— if an incomplete type (3.9) is used as a template argument when instantiating a template component.

It works with almost all STL implementations, but not with STLport-5.1.5/MSVC-8.0-SP1.


Build log:

instantiate_cpp_grammar.cpp
STLport: Auto linking to stlportstld.5.1.lib
E:\.my\projects\install\.msvc\STLport-5.1.5\stlport\stl/type_traits.h(249) : error C2139: 'boost::spirit::tree_node<T>' : an undefined class is not allowed as an argument to compiler intrinsic type trait '__has_trivial_constructor'
        with
        [
            T=boost::spirit::node_val_data<boost::wave::cpplexer::lex_iterator<token_type>,boost::spirit::nil_t>
        ]
        E:\.my\projects\install\.msvc\STLport-5.1.5\stlport\stl/_vector.h(137) : see reference to class template instantiation 'stlpd_std::__type_traits<_Tp>' being compiled
        with
        [
            _Tp=boost::spirit::tree_node<boost::spirit::node_val_data<boost::wave::cpplexer::lex_iterator<token_type>,boost::spirit::nil_t>>
        ]
        E:\.my\projects\install\.msvc\STLport-5.1.5\stlport\stl/debug/_iterator.h(381) : see reference to class template instantiation 'stlpd_std::priv::_NonDbg_vector<_Tp,_Alloc>' being compiled
        with
        [
            _Tp=boost::spirit::tree_node<boost::spirit::node_val_data<boost::wave::cpplexer::lex_iterator<token_type>,boost::spirit::nil_t>>,
            _Alloc=stlpd_std::allocator<boost::spirit::tree_node<boost::spirit::node_val_data<boost::wave::cpplexer::lex_iterator<token_type>,boost::spirit::nil_t>>>
        ]
        E:\.my\projects\install\.msvc\STLport-5.1.5\stlport\stl/debug/_vector.h(106) : see reference to class template instantiation 'stlpd_std::priv::__construct_checker<_Container>' being compiled
        with
        [
            _Container=stlpd_std::priv::_NonDbg_vector<boost::spirit::tree_node<boost::spirit::node_val_data<boost::wave::cpplexer::lex_iterator<token_type>,boost::spirit::nil_t>>,stlpd_std::allocator<boost::spirit::tree_node<boost::spirit::node_val_data<boost::wave::cpplexer::lex_iterator<token_type>,boost::spirit::nil_t>>>>
        ]
        .\boost/spirit/tree/common.hpp(69) : see reference to class template instantiation 'stlpd_std::vector<_Tp,_Alloc>' being compiled
        with
        [
            _Tp=boost::spirit::tree_node<boost::spirit::node_val_data<boost::wave::cpplexer::lex_iterator<token_type>,boost::spirit::nil_t>>,
            _Alloc=stlpd_std::allocator<boost::spirit::tree_node<boost::spirit::node_val_data<boost::wave::cpplexer::lex_iterator<token_type>,boost::spirit::nil_t>>>
        ]
        .\boost/spirit/tree/common.hpp(542) : see reference to class template instantiation 'boost::spirit::tree_node<T>' being compiled
        with
        [
            T=boost::spirit::node_val_data<boost::wave::cpplexer::lex_iterator<token_type>,boost::spirit::nil_t>
        ]
        .\boost/spirit/tree/common.hpp(1454) : see reference to class template instantiation 'boost::spirit::tree_match<IteratorT,NodeFactoryT,T>' being compiled
        with
        [
            IteratorT=boost::wave::cpplexer::lex_iterator<token_type>,
            NodeFactoryT=boost::wave::grammars::cpp_grammar_gen<lexer_type,token_sequence_type>::node_factory_type,
            T=boost::spirit::nil_t
        ]
        .\boost/wave/grammars/cpp_grammar.hpp(723) : see reference to class template instantiation 'boost::spirit::tree_parse_info<IteratorT,NodeFactoryT>' being compiled
        with
        [
            IteratorT=boost::wave::cpplexer::lex_iterator<token_type>,
            NodeFactoryT=boost::wave::grammars::cpp_grammar_gen<lexer_type,token_sequence_type>::node_factory_type
        ]
        .\boost/wave/grammars/cpp_grammar.hpp(723) : while compiling class template member function 'boost::spirit::tree_parse_info<IteratorT,NodeFactoryT> boost::wave::grammars::cpp_grammar_gen<LexIteratorT,TokenContainerT>::parse_cpp_grammar(const boost::wave::cpplexer::lex_iterator<TokenT> &,const boost::wave::cpplexer::lex_iterator<TokenT> &,const boost::wave::util::file_position<StringT> &,bool &,boost::wave::cpplexer::lex_token<> &,stlpd_std::list<_Tp,_Alloc> &)'
        with
        [
            IteratorT=boost::wave::cpplexer::lex_iterator<token_type>,
            NodeFactoryT=boost::wave::grammars::cpp_grammar_gen<lexer_type,token_sequence_type>::node_factory_type,
            LexIteratorT=lexer_type,
            TokenContainerT=token_sequence_type,
            TokenT=token_type,
            StringT=boost::wave::util::flex_string<char,stlpd_std::char_traits<char>,stlpd_std::allocator<char>,boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char>>>,
            _Tp=token_type,
            _Alloc=boost::fast_pool_allocator<token_type>
        ]
        libs\wave\src\instantiate_cpp_grammar.cpp(47) : see reference to class template instantiation 'boost::wave::grammars::cpp_grammar_gen<LexIteratorT,TokenContainerT>' being compiled
        with
        [
            LexIteratorT=lexer_type,
            TokenContainerT=token_sequence_type
        ]

Change History (1)

comment:1 by Hartmut Kaiser, 12 years ago

Resolution: wontfix
Status: newclosed

I'll go ahead and close this ticket as the problem does not persist in the current (and newest) version of Spirit. It's not related to Wave even if it is triggered by Wave ATM. We will port Wave over to the new version of Spirit soon, so it will be a no issue in this concrete context as well.

Note: See TracTickets for help on using tickets.