This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Results for g++ 3.1 application testing on i686-pc-linux-gnu
- From: Peter Schmid <schmid at snake dot iap dot physik dot tu-darmstadt dot de>
- To: <jason at redhat dot com>
- Cc: <libstdc++ at gcc dot gnu dot org>
- Date: Sat, 16 Mar 2002 16:40:31 +0100 (CET)
- Subject: Re: Results for g++ 3.1 application testing on i686-pc-linux-gnu
When submitting patches fixing problems with the type checking code
from boost to John Maddock I asked him whether the remaining seven
(expected) failures for empty_* types in
libs/type_traits/tests/object_type_traits_test.cpp are failures
according to the standard or not.
the checking value of boost::has_trivial_constructor<empty_UDT>::value...failed
found: 0 expected 1
checking value of boost::has_trivial_copy<empty_UDT>::value...failed
found: 0 expected 1
checking value of boost::has_trivial_assign<empty_UDT>::value...failed
found: 0 expected 1
checking value of boost::has_nothrow_constructor<empty_UDT>::value...failed
found: 0 expected 1
checking value of boost::has_nothrow_copy<empty_UDT>::value...failed
found: 0 expected 1
checking value of boost::has_nothrow_assign<empty_UDT>::value...failed
found: 0 expected 1
checking value of boost::is_empty<empty_union_UDT>::value...failed
boost::is_empty<empty_union_UDT>::value does not compile on this compiler
201 tests completed, 7 failures found, 7 failures expected from this compiler.
His first reply was:
"The "failures" for empty_* types are not failures
according to the standard - it just means that the compiler is not applying
the zero sized base class optimization, so we can't detect empty base
classes." He responded with a test case regarding the zero value
optimization which gcc 3.1 passes.
On my request to be more specific on the nature of
the seven failures I got no reply.
Well, I narrowed the first of these tests down to some lines. Here is the
test.
#include <iostream>
#define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) false
int cpp_main(); // prototype for user's cpp_main()
namespace boost{
template <typename T>
struct has_trivial_constructor
{
static const bool value = BOOST_HAS_TRIVIAL_CONSTRUCTOR(T);
};
template< class Generator > // Generator is function object returning int
int catch_exceptions( Generator function_object)
{
int result = function_object();
return result;
}
namespace test
{
class cpp_main_caller
{
public:
cpp_main_caller() {}
int operator()() { return cpp_main(); }
};
}
}
int main()
{
return boost::catch_exceptions( boost::test::cpp_main_caller());
}
unsigned failures = 0;
unsigned test_count = 0;
unsigned int expected_failures = 0;
int check_result()
{
std::cout << test_count << " tests completed, "
<< failures << " failures found, "
<< expected_failures << " failures expected from this compiler." << std::endl;
return (failures == expected_failures)
? 0
: (failures != 0) ? static_cast<int>(failures) : -1;
}
template <bool b>
struct checker
{
static void check(bool, bool, const char*, bool){ ++test_count; }
};
template <>
struct checker<false>
{
static void check(bool o, bool n, const char* name, bool soft)
{
++test_count;
++failures;
if(soft)++expected_failures;
std::cout << "checking value of " << name << "...failed" << std::endl;
std::cout << "\tfound: " << n << " expected " << o << std::endl;
}
};
template <class T>
struct typify{};
template <class T, class U>
struct type_checker
{
static void check(const char* TT, const char* TU, const char* expression)
{
++test_count;
if(typeid(typify<T>) != typeid(typify<U>))
{
++failures;
std::cout << "checking type of " << expression << "...failed" << std::endl;
std::cout << " evaluating: type_checker<" << TT << "," << expression << ">" << std::endl;
std::cout << " expected: type_checker<" << TT << "," << TT << ">" << std::endl;
std::cout << " but got: " << typeid(type_checker<T,U>).name() << std::endl;
}
}
};
template <class T>
struct type_checker<T,T>
{
static void check(const char*, const char*, const char*)
{
++test_count;
}
};
#define soft_value_test(v, x) checker<(v == x)>::check(v, x, #x, true);
struct empty_UDT
{
~empty_UDT(){};
empty_UDT& operator=(const empty_UDT&){ return *this; }
bool operator==(const empty_UDT&)const
{ return true; }
};
int cpp_main()
{
soft_value_test(true, boost::has_trivial_constructor<empty_UDT>::value)
return check_result();
}
When I run the executable compiled by gcc version 3.1 20020313 on my
686-pc-linux-gnu box, the output is:
checking value of boost::has_trivial_constructor<empty_UDT>::value...failed
found: 0 expected 1
1 tests completed, 1 failures found, 1 failures expected from this compiler.
I hope I made no mistake when I prepared the test case. Maybe an
expert can tell what is going on.
Hope this helps,
Peter Schmid