|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-02-21 20:07:54
I've fixed is_POD for array types on compilers not supporting partial
specialization. The patch is appended but I have also checked it in. It's
amazing how many competent compilers the workaround code doesn't compile on,
but AFAICT it is conforming.
About the testing methodology: It seems as though the tests are engineered
so we won't know when something gets fixed. Tests which are expected to fail
to compile on a given compiler never actually happen. The number of failures
reportedly expected for a compiler (e.g. msvc/object_type_traits_test) may
far exceed the number set in the expected_failures variable for any given
test, due to "soft failures". Expectations of success don't seem to be tied
to the version of the compiler in use. The worst part about this is that,
because fixes are hidden, so are subsequent regressions.
What can we do so that the status of a given trait on a given compiler
is more-reliably reported? We have everything we need in status/Jamfile in
order to get fine-grained and accurate reports.
I also made the following change. It causes tests to fail if they don't
match their expected number of failures exactly. I needed to do that in
order to see that the change fixed anything:
######################
Index: boost/type_traits/type_traits_test.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/type_traits/type_traits_test.hpp,v
retrieving revision 1.16
diff -r1.16 type_traits_test.hpp
45c45
< return (failures <= expected_failures) ? 0 : failures;
--- > return (failures == expected_failures) ? 0 : (failures != 0) ? failures : -1; ###################### That uncovered the following discrepancies (so expect the regression status to get much worse until we correct our expectations): succeeded-test-file e:\boost-build\status\bin\alignment_test.test\metrowerks\debug\runtime-link- dynamic\alignment_test.test ***************** failed above test: alignment_test ******************** 14 tests completed, 0 failures found, 5 failures expected from this compiler. succeeded-test-file e:\boost-build\status\bin\composite_traits_test.test\msvc\debug\runtime-link -dynamic\composite_traits_test.test ***************** failed above test: composite_traits_test ******************** 82 tests completed, 0 failures found, 1 failures expected from this compiler. succeeded-test-file e:\boost-build\status\bin\cv_traits_test.test\gcc\debug\runtime-link-dynamic \cv_traits_test.test * ***************** failed above test: cv_traits_test ******************** checking value of boost::is_const<cr_type>::value...failed boost::is_const<cr_type>::value does not compile on this compiler 24 tests completed, 1 failures found, 2 failures expected from this compiler. succeeded-test-file e:\boost-build\status\bin\cv_traits_test.test\mingw\debug\runtime-link-dynam ic\cv_traits_test.test * ***************** failed above test: cv_traits_test ******************** checking value of boost::is_const<cr_type>::value...failed boost::is_const<cr_type>::value does not compile on this compiler 24 tests completed, 1 failures found, 2 failures expected from this compiler. succeeded-test-file e:\boost-build\status\bin\is_convertible_test.test\borland\debug\runtime-lin k-dynamic\is_convertible_test.test * ***************** failed above test: is_convertible_test ******************** * succeeded-test-file e:\boost-build\status\bin\is_convertible_test.test\metrowerks\debug\runtime- link-dynamic\is_convertible_test.test * ***************** failed above test: is_convertible_test ******************** <snip> 54 tests completed, 35 failures found, 0 failures expected from this compiler. succeeded-test-file e:\boost-build\status\bin\object_type_traits_test.test\intel-win32\debug\run time-link-dynamic\object_type_traits_test.test * ***************** failed above test: object_type_traits_test ******************** <snip> 201 tests completed, 7 failures found, 10 failures expected from this compiler. succeeded-test-file e:\boost-build\status\bin\object_type_traits_test.test\metrowerks\debug\runt ime-link-dynamic\object_type_traits_test.test * ***************** failed above test: object_type_traits_test ******************** <snip> 201 tests completed, 21 failures found, 19 failures expected from this compiler. ###################### ? libs/type_traits/tests/subjamfile Index: boost/type_traits/object_traits.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/type_traits/object_traits.hpp,v retrieving revision 1.14 diff -r1.14 object_traits.hpp 135a136,137 > > #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 138,139c140,142 < BOOST_STATIC_CONSTANT(bool, value = < (::boost::type_traits::ice_or< --- > BOOST_STATIC_CONSTANT( > bool, value = > (::boost::type_traits::ice_or< 143c146 < >::value)); --- > >::value)); 145c148 < #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION --- > 150a154,227 > #else > namespace detail > { > template <bool is_array = false> struct is_POD_helper; > } > > template <typename T> struct is_POD > > BOOST_STATIC_CONSTANT( > bool, value = ( > ::boost::detail::is_POD_helper< > ::boost::is_array<T>::value > >::template apply<T>::value > ) > ); > }; > > namespace detail > { > template <bool is_array> > struct is_POD_helper > { > template <typename T> struct apply > { > BOOST_STATIC_CONSTANT( > bool, value = > (::boost::type_traits::ice_or< > ::boost::is_scalar<T>::value, > ::boost::is_void<T>::value, > BOOST_IS_POD(T) > >::value)); > }; > }; > > template <bool b> > struct bool_to_type > { > typedef ::boost::type_traits::no_type type; > }; > > template <> > struct bool_to_type<true> > { > typedef ::boost::type_traits::yes_type type; > }; > > template <class ArrayType> > struct is_POD_array_helper > { > typedef > #if !defined(__BORLANDC__) || __BORLANDC__ > 0x551 > typename > #endif > ::boost::detail::bool_to_type<(::boost::is_POD<ArrayType>::value)>::type type; > > type instance() const; > }; > > template <class T> > is_POD_array_helper<T> is_POD_array(T*); > > template <> > struct is_POD_helper<true> > { > template <typename T> struct apply > { > static T& help(); > > BOOST_STATIC_CONSTANT( > bool, value = > sizeof(is_POD_array(help()).instance()) > 1); > }; > }; > } Index: libs/type_traits/tests/object_type_traits_test.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/type_traits/tests/object_type_traits_test.cpp,v retrieving revision 1.17 diff -r1.17 object_type_traits_test.cpp 308c308 < unsigned int expected_failures = 24; --- > unsigned int expected_failures = 16; +---------------------------------------------------------------+ David Abrahams C++ Booster (http://www.boost.org) O__ == Pythonista (http://www.python.org) c/ /'_ == resume: http://users.rcn.com/abrahams/resume.html (*) \(*) == email: david.abrahams_at_[hidden] +---------------------------------------------------------------+
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk