Opened 14 years ago

Closed 14 years ago

#2402 closed Bugs (invalid)

boost::spirit (boost-1.36.0) parsers fail to compile on MSVS 9.0 with struct member alignment being set to 1 byte

Reported by: slava@… Owned by: Joel de Guzman
Milestone: Boost 1.37.0 Component: spirit
Version: Boost 1.36.0 Severity: Problem
Keywords: Cc:

Description

When I try to compile the following code with MSVS 9.0 and boost-1.36.0 with struct member alignment being set to 1 byte, it fails with boost::STATIC_ASSERTION_FAILURE

The code:

parse_info<std::wstring::const_iterator> pi= parse(SrchNM.begin(), SrchNM.end(),
			as_lower_d[
			!(str_p("w/"))[assign_a(prefix_is_w, true)] //prefix
			>> !list_p(
				(+(anychar_p - '=' - ',' - '@'))[assign_a(last_attr_name)]
				>> '=' 
				>> (+(anychar_p - '=' - ',' - '@'))[MapInserter<StrMap>(srch_attrs, last_attr_name)]
				,
				','
				)
			>> !ch_p('@')
			>> (*anychar_p)[assign_a(srch_word)]
			]);

The errors reported:

1>d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(206) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
1>        with
1>        [
1>            x=false
1>        ]
1>        d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(218) : see reference to class template instantiation 'boost::detail::type_with_alignment_imp<Align>' being compiled
1>        with
1>        [
1>            Align=2
1>        ]
1>        d:\users\slava\etap\external\boost\boost\optional\optional.hpp(112) : see reference to class template instantiation 'boost::type_with_alignment<Align>' being compiled
1>        with
1>        [
1>            Align=2
1>        ]
1>        d:\users\slava\etap\external\boost\boost\optional\optional.hpp(113) : see reference to class template instantiation 'boost::optional_detail::aligned_storage<T>::dummy_u' being compiled
1>        with
1>        [
1>            T=unsigned short
1>        ]
1>        d:\users\slava\etap\external\boost\boost\optional\optional.hpp(448) : see reference to class template instantiation 'boost::optional_detail::aligned_storage<T>' being compiled
1>        with
1>        [
1>            T=unsigned short
1>        ]
1>        d:\users\slava\etap\external\boost\boost\optional\optional.hpp(455) : see reference to class template instantiation 'boost::optional_detail::optional_base<T>' being compiled
1>        with
1>        [
1>            T=unsigned short
1>        ]
1>        d:\users\slava\etap\external\boost\boost\spirit\home\classic\core\match.hpp(69) : see reference to class template instantiation 'boost::optional<T>' being compiled
1>        with
1>        [
1>            T=unsigned short
1>        ]
1>        d:\users\slava\etap\external\boost\boost\spirit\home\classic\core\composite\optional.hpp(56) : see reference to class template instantiation 'boost::spirit::match<T>' being compiled
1>        with
1>        [
1>            T=unsigned short
1>        ]
1>        d:\users\slava\etap\external\boost\boost\spirit\home\classic\core\composite\sequence.hpp(56) : see reference to function template instantiation 'boost::spirit::match<boost::spirit::nil_t> boost::spirit::optional<S>::parse<ScannerT>(const ScannerT &) const' being compiled
1>        with
1>        [
1>            S=boost::spirit::chlit<char>,
1>            ScannerT=boost::spirit::scanner<std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>,boost::spirit::scanner_policies<boost::spirit::inhibit_case_iteration_policy<boost::spirit::iteration_policy>,boost::spirit::match_policy,boost::spirit::action_policy>>
1>        ]
1>        d:\users\slava\etap\external\boost\boost\spirit\home\classic\core\composite\sequence.hpp(55) : see reference to function template instantiation 'boost::spirit::match<boost::spirit::nil_t> boost::spirit::sequence<A,B>::parse<ScannerT>(const ScannerT &) const' being compiled
1>        with
1>        [
1>            A=boost::spirit::sequence<boost::spirit::optional<boost::spirit::action<boost::spirit::strlit<const char *>,boost::spirit::ref_const_ref_actor<bool,bool,boost::spirit::assign_action>>>,boost::spirit::optional<boost::spirit::list_parser<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>,boost::spirit::chlit<char>>,boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,`anonymous-namespace'::MapInserter<StrMap>>>,boost::spirit::chlit<char>,boost::spirit::no_list_endtoken,boost::spirit::binary_parser_category>>>,
1>            B=boost::spirit::optional<boost::spirit::chlit<char>>,
1>            ScannerT=boost::spirit::scanner<std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>,boost::spirit::scanner_policies<boost::spirit::inhibit_case_iteration_policy<boost::spirit::iteration_policy>,boost::spirit::match_policy,boost::spirit::action_policy>>
1>        ]
1>        d:\users\slava\etap\external\boost\boost\spirit\home\classic\core\composite\impl\directives.ipp(141) : see reference to function template instantiation 'boost::spirit::match<boost::spirit::nil_t> boost::spirit::sequence<A,B>::parse<boost::spirit::scanner<IteratorT,PoliciesT>>(const ScannerT &) const' being compiled
1>        with
1>        [
1>            A=boost::spirit::sequence<boost::spirit::sequence<boost::spirit::optional<boost::spirit::action<boost::spirit::strlit<const char *>,boost::spirit::ref_const_ref_actor<bool,bool,boost::spirit::assign_action>>>,boost::spirit::optional<boost::spirit::list_parser<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>,boost::spirit::chlit<char>>,boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,`anonymous-namespace'::MapInserter<StrMap>>>,boost::spirit::chlit<char>,boost::spirit::no_list_endtoken,boost::spirit::binary_parser_category>>>,boost::spirit::optional<boost::spirit::chlit<char>>>,
1>            B=boost::spirit::action<boost::spirit::kleene_star<boost::spirit::anychar_parser>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>,
1>            IteratorT=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>,
1>            PoliciesT=boost::spirit::scanner_policies<boost::spirit::inhibit_case_iteration_policy<boost::spirit::iteration_policy>,boost::spirit::match_policy,boost::spirit::action_policy>,
1>            ScannerT=boost::spirit::scanner<std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>,boost::spirit::scanner_policies<boost::spirit::inhibit_case_iteration_policy<boost::spirit::iteration_policy>,boost::spirit::match_policy,boost::spirit::action_policy>>
1>        ]
1>        d:\users\slava\etap\external\boost\boost\spirit\home\classic\core\composite\directives.hpp(163) : see reference to function template instantiation 'RT boost::spirit::impl::inhibit_case_parser_parse<result_t,T,ScannerT>(const ST &,const ScannerT &,const boost::spirit::iteration_policy &)' being compiled
1>        with
1>        [
1>            RT=result_t,
1>            T=boost::spirit::sequence<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::optional<boost::spirit::action<boost::spirit::strlit<const char *>,boost::spirit::ref_const_ref_actor<bool,bool,boost::spirit::assign_action>>>,boost::spirit::optional<boost::spirit::list_parser<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>,boost::spirit::chlit<char>>,boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,`anonymous-namespace'::MapInserter<StrMap>>>,boost::spirit::chlit<char>,boost::spirit::no_list_endtoken,boost::spirit::binary_parser_category>>>,boost::spirit::optional<boost::spirit::chlit<char>>>,boost::spirit::action<boost::spirit::kleene_star<boost::spirit::anychar_parser>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>>,
1>            ScannerT=boost::spirit::scanner<std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>,boost::spirit::scanner_policies<>>,
1>            ST=boost::spirit::sequence<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::optional<boost::spirit::action<boost::spirit::strlit<const char *>,boost::spirit::ref_const_ref_actor<bool,bool,boost::spirit::assign_action>>>,boost::spirit::optional<boost::spirit::list_parser<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>,boost::spirit::chlit<char>>,boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,`anonymous-namespace'::MapInserter<StrMap>>>,boost::spirit::chlit<char>,boost::spirit::no_list_endtoken,boost::spirit::binary_parser_category>>>,boost::spirit::optional<boost::spirit::chlit<char>>>,boost::spirit::action<boost::spirit::kleene_star<boost::spirit::anychar_parser>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>>
1>        ]
1>        d:\users\slava\etap\external\boost\boost\spirit\home\classic\core\impl\parser.ipp(30) : see reference to function template instantiation 'boost::spirit::match<boost::spirit::nil_t> boost::spirit::inhibit_case<ParserT>::parse<boost::spirit::scanner<IteratorT,PoliciesT>>(const ScannerT &) const' being compiled
1>        with
1>        [
1>            ParserT=boost::spirit::sequence<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::optional<boost::spirit::action<boost::spirit::strlit<const char *>,boost::spirit::ref_const_ref_actor<bool,bool,boost::spirit::assign_action>>>,boost::spirit::optional<boost::spirit::list_parser<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>,boost::spirit::chlit<char>>,boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,`anonymous-namespace'::MapInserter<StrMap>>>,boost::spirit::chlit<char>,boost::spirit::no_list_endtoken,boost::spirit::binary_parser_category>>>,boost::spirit::optional<boost::spirit::chlit<char>>>,boost::spirit::action<boost::spirit::kleene_star<boost::spirit::anychar_parser>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>>,
1>            IteratorT=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>,
1>            PoliciesT=boost::spirit::scanner_policies<>,
1>            ScannerT=boost::spirit::scanner<std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>,boost::spirit::scanner_policies<>>
1>        ]
1>        d:\users\slava\etap\projects\tagged\tgtproc\tgtproc.cpp(1329) : see reference to function template instantiation 'boost::spirit::parse_info<IteratorT> boost::spirit::parse<std::_String_iterator<_Elem,_Traits,_Alloc>,boost::spirit::inhibit_case<ParserT>>(const IteratorT &,const IteratorT &,const boost::spirit::parser<DerivedT> &)' being compiled
1>        with
1>        [
1>            IteratorT=std::_String_iterator<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>,
1>            _Elem=wchar_t,
1>            _Traits=std::char_traits<wchar_t>,
1>            _Alloc=std::allocator<wchar_t>,
1>            ParserT=boost::spirit::sequence<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::optional<boost::spirit::action<boost::spirit::strlit<const char *>,boost::spirit::ref_const_ref_actor<bool,bool,boost::spirit::assign_action>>>,boost::spirit::optional<boost::spirit::list_parser<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>,boost::spirit::chlit<char>>,boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,`anonymous-namespace'::MapInserter<StrMap>>>,boost::spirit::chlit<char>,boost::spirit::no_list_endtoken,boost::spirit::binary_parser_category>>>,boost::spirit::optional<boost::spirit::chlit<char>>>,boost::spirit::action<boost::spirit::kleene_star<boost::spirit::anychar_parser>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>>,
1>            DerivedT=boost::spirit::inhibit_case<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::optional<boost::spirit::action<boost::spirit::strlit<const char *>,boost::spirit::ref_const_ref_actor<bool,bool,boost::spirit::assign_action>>>,boost::spirit::optional<boost::spirit::list_parser<boost::spirit::sequence<boost::spirit::sequence<boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>,boost::spirit::chlit<char>>,boost::spirit::action<boost::spirit::positive<boost::spirit::difference<boost::spirit::difference<boost::spirit::difference<boost::spirit::anychar_parser,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>,boost::spirit::chlit<char>>>,`anonymous-namespace'::MapInserter<StrMap>>>,boost::spirit::chlit<char>,boost::spirit::no_list_endtoken,boost::spirit::binary_parser_category>>>,boost::spirit::optional<boost::spirit::chlit<char>>>,boost::spirit::action<boost::spirit::kleene_star<boost::spirit::anychar_parser>,boost::spirit::ref_value_actor<std::wstring,boost::spirit::assign_action>>>>
1>        ]
1>d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(207) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
1>        with
1>        [
1>            x=false
1>        ]

Increasing struct member alignment to 2 or more bytes solves the problem. The same code gives no errors with boost-1.35.0 even with alignment=1byte.

Change History (5)

comment:1 by Joel de Guzman, 14 years ago

Seems more like a problem of boost optional than spirit. You can try isolating the code with using boost optional alone (without spirit). If the problem persists, then you can send the problem report to the optional author.

comment:2 by slava@…, 14 years ago

Yes, it appears to be a problem with boost::optional. The following simple test fails if compiled with struct member alignment=1 or 2 bytes, and everything is OK when alignment is set to 4 or more bytes:

#include <boost/optional.hpp>

boost::optional<int> test_func(int i) {
	if(i) return boost::optional<int>(1234);
	else return boost::optional<int>();
}


int main(int argc, char* argv[])
{
	test_func(1);
	return 0;
}

The errors are:

d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(206) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
1>        with
1>        [
1>            x=false
1>        ]
1>        d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(218) : see reference to class template instantiation 'boost::detail::type_with_alignment_imp<Align>' being compiled
1>        with
1>        [
1>            Align=4
1>        ]
1>        d:\users\slava\etap\external\boost\boost\optional\optional.hpp(112) : see reference to class template instantiation 'boost::type_with_alignment<Align>' being compiled
1>        with
1>        [
1>            Align=4
1>        ]
1>        d:\users\slava\etap\external\boost\boost\optional\optional.hpp(113) : see reference to class template instantiation 'boost::optional_detail::aligned_storage<T>::dummy_u' being compiled
1>        with
1>        [
1>            T=int
1>        ]
1>        d:\users\slava\etap\external\boost\boost\optional\optional.hpp(448) : see reference to class template instantiation 'boost::optional_detail::aligned_storage<T>' being compiled
1>        with
1>        [
1>            T=int
1>        ]
1>        d:\users\slava\etap\external\boost\boost\optional\optional.hpp(455) : see reference to class template instantiation 'boost::optional_detail::optional_base<T>' being compiled
1>        with
1>        [
1>            T=int
1>        ]
1>        d:\users\slava\test\test.cpp(8) : see reference to class template instantiation 'boost::optional<T>' being compiled
1>        with
1>        [
1>            T=int
1>        ]
1>d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(207) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
1>        with
1>        [
1>            x=false
1>        ]

comment:3 by Joel de Guzman, 14 years ago

Ok. I suggest you add a new trac ticket for boost optional and close this one.

comment:4 by slava@…, 14 years ago

I've created ticket #2409, but I have no permission to close this one.

comment:5 by Joel de Guzman, 14 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.