Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#13387 closed Bugs (fixed)

Test header fails to compile

Reported by: Tony Lewis <tonyelewis@…> Owned by: Raffi Enficiaud
Milestone: Boost 1.67.0 Component: test
Version: Boost Development Trunk Severity: Problem
Keywords: test, header, data Cc:

Description

The Boost header policy (http://www.boost.org/development/header.html) requires:

Make sure that a translation unit consisting of just the contents of the header file will compile successfully.

...but compiling:

#include <boost/test/data/test_case.hpp>

...gives errors...

In file included from geoff.cpp:1:0:
/tmp/test-develop/include/boost/test/data/test_case.hpp:198:18: error: ‘list’ in namespace ‘std’ does not name a template type
     mutable std::list<test_unit*>   m_test_cases;
                  ^~~~
/tmp/test-develop/include/boost/test/data/test_case.hpp: In constructor ‘boost::unit_test::data::ds_detail::test_case_gen<TestCase, DataSet>::test_case_gen(boost::unit_test::data::ds_detail::test_case_gen<TestCase, DataSet>&&)’:
/tmp/test-develop/include/boost/test/data/test_case.hpp:138:7: error: class ‘boost::unit_test::data::ds_detail::test_case_gen<TestCase, DataSet>’ does not have any field named ‘m_test_cases’
     , m_test_cases( std::move(gen.m_test_cases) )
       ^~~~~~~~~~~~
/tmp/test-develop/include/boost/test/data/test_case.hpp: In member function ‘virtual boost::unit_test::test_unit* boost::unit_test::data::ds_detail::test_case_gen<TestCase, DataSet>::next() const’:
/tmp/test-develop/include/boost/test/data/test_case.hpp:153:13: error: ‘m_test_cases’ was not declared in this scope
         if( m_test_cases.empty() )
             ^~~~~~~~~~~~
/tmp/test-develop/include/boost/test/data/test_case.hpp:156:26: error: ‘m_test_cases’ was not declared in this scope
         test_unit* res = m_test_cases.front();
                          ^~~~~~~~~~~~
/tmp/test-develop/include/boost/test/data/test_case.hpp: In member function ‘void boost::unit_test::data::ds_detail::test_case_gen<TestCase, DataSet>::operator()(Arg&& ...) const’:
/tmp/test-develop/include/boost/test/data/test_case.hpp:178:9: error: ‘m_test_cases’ was not declared in this scope
         m_test_cases.push_back(
         ^~~~~~~~~~~~

This follows on from ticket:12228.

Change History (5)

comment:1 by Tony Lewis <tonyelewis@…>, 5 years ago

I should say: the above errors are from GCC 6.2.

Clang 5.0 gives:

In file included from geoff.cpp:1:
In file included from /tmp/test-develop/include/boost/test/data/test_case.hpp:17:
In file included from /tmp/test-develop/include/boost/test/data/dataset.hpp:16:
In file included from /tmp/test-develop/include/boost/test/data/monomorphic.hpp:16:
In file included from /tmp/test-develop/include/boost/test/data/monomorphic/array.hpp:17:
In file included from /tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:19:
/tmp/test-develop/include/boost/test/utils/is_forward_iterable.hpp:204:5: error: unknown type name 'BOOST_STATIC_ASSERT'
    BOOST_STATIC_ASSERT((is_forward_iterable<T>::value)); //, "only for forward iterable types");
    ^
/tmp/test-develop/include/boost/test/utils/is_forward_iterable.hpp:204:50: error: non-friend class member 'value' cannot have a qualified name
    BOOST_STATIC_ASSERT((is_forward_iterable<T>::value)); //, "only for forward iterable types");
                         ~~~~~~~~~~~~~~~~~~~~~~~~^
/tmp/test-develop/include/boost/test/utils/is_forward_iterable.hpp:221:22: error: no template named 'add_const' in namespace 'boost'; did you mean 'std::add_const'?
    typedef typename boost::add_const<T>::type T_const;
                     ^~~~~~~
/opt/clang+llvm-5.0.0-linux-x86_64-ubuntu16.04/bin/../include/c++/v1/type_traits:1033:50: note: 'std::add_const' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const
                                                 ^
In file included from geoff.cpp:1:
In file included from /tmp/test-develop/include/boost/test/data/test_case.hpp:17:
In file included from /tmp/test-develop/include/boost/test/data/dataset.hpp:16:
In file included from /tmp/test-develop/include/boost/test/data/monomorphic.hpp:16:
In file included from /tmp/test-develop/include/boost/test/data/monomorphic/array.hpp:17:
In file included from /tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:19:
/tmp/test-develop/include/boost/test/utils/is_forward_iterable.hpp:222:22: error: no template named 'add_pointer' in namespace 'boost'; did you mean 'std::add_pointer'?
    typedef typename boost::add_pointer<T_const>::type const_iterator;
                     ^~~~~~~
/opt/clang+llvm-5.0.0-linux-x86_64-ubuntu16.04/bin/../include/c++/v1/type_traits:1171:50: note: 'std::add_pointer' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
                                                 ^
In file included from geoff.cpp:1:
In file included from /tmp/test-develop/include/boost/test/data/test_case.hpp:17:
In file included from /tmp/test-develop/include/boost/test/data/dataset.hpp:16:
In file included from /tmp/test-develop/include/boost/test/data/monomorphic.hpp:16:
In file included from /tmp/test-develop/include/boost/test/data/monomorphic/array.hpp:17:
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:122:33: error: use of undeclared identifier 'is_container_forward_iterable'
inline typename std::enable_if<!is_container_forward_iterable<T>::value && 
                                ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:122:63: error: 'T' does not refer to a value
inline typename std::enable_if<!is_container_forward_iterable<T>::value && 
                                                              ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:121:19: note: declared here
template<typename T>
                  ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:122:67: error: definition or redeclaration of 'value' cannot name the global scope
inline typename std::enable_if<!is_container_forward_iterable<T>::value && 
                                                                ~~^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:122:67: error: no member named 'value' in the global namespace
inline typename std::enable_if<!is_container_forward_iterable<T>::value && 
                                                                ~~^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:122:72: error: expected ';' at end of declaration
inline typename std::enable_if<!is_container_forward_iterable<T>::value && 
                                                                       ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:123:32: error: expected unqualified-id
                               !monomorphic::is_dataset<T>::value &&
                               ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:132:32: error: use of undeclared identifier 'is_container_forward_iterable'
inline typename std::enable_if<is_container_forward_iterable<C>::value,monomorphic::collection<C>>::type
                               ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:132:62: error: 'C' does not refer to a value
inline typename std::enable_if<is_container_forward_iterable<C>::value,monomorphic::collection<C>>::type
                                                             ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:131:19: note: declared here
template<typename C>
                  ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:132:66: error: definition or redeclaration of 'value' cannot name the global scope
inline typename std::enable_if<is_container_forward_iterable<C>::value,monomorphic::collection<C>>::type
                                                               ~~^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:132:71: error: a template declaration can only declare a single entity
inline typename std::enable_if<is_container_forward_iterable<C>::value,monomorphic::collection<C>>::type
                                                                      ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:159:1: error: redefinition of 'make' as different kind of symbol
make( std::initializer_list<T>&& );
^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:152:1: note: previous definition is here
make( char const* str );
^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:159:12: error: no member named 'initializer_list' in namespace 'std'
make( std::initializer_list<T>&& );
      ~~~~~^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:159:29: error: 'T' does not refer to a value
make( std::initializer_list<T>&& );
                            ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:157:19: note: declared here
template<typename T>
                  ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:159:34: error: expected identifier
make( std::initializer_list<T>&& );
                                 ^
/tmp/test-develop/include/boost/test/data/monomorphic/fwd.hpp:168:35: error: no template named 'declval'; did you mean 'std::declval'?
    typedef decltype( data::make( declval<DataSet>() ) ) type;
                                  ^
/opt/clang+llvm-5.0.0-linux-x86_64-ubuntu16.04/bin/../include/c++/v1/type_traits:1117:1: note: 'std::declval' declared here
declval();
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

comment:2 by Raffi Enficiaud, 5 years ago

Milestone: To Be DeterminedBoost 1.67.0
Owner: changed from Gennadiy Rozental to Raffi Enficiaud
Status: newassigned

comment:3 by Raffi Enficiaud, 5 years ago

On develop

comment:4 by Raffi Enficiaud, 5 years ago

Resolution: fixed
Status: assignedclosed

On master

comment:5 by Tony E Lewis <tonyelewis@…>, 5 years ago

Thanks very much - this now works for me.

It still fails under Clang but that seems to be because Clang defaults to -std=c++98 and that header requires ≥ C++11. When compiling that header as C++98 under GCC, the relevant error about the required standard is the first error but under Clang that message is a bit buried. If you could make it the first error under both, that might save some users a lot of time.

Note: See TracTickets for help on using tickets.