Boost logo

Boost :

Subject: [boost] [type_traits] is_base_of<> GCC error for v1.42.0
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2010-05-08 16:38:20


Hello all,

The following code gives the GCC compiler error below for Boost 1.42.0
while it compiles just fine for Boost 1.34.1.

Is this a bug in Boost.TypeTraits for 1.42.0?

    // File: b00.cpp
    #include <boost/type_traits.hpp>
    #include <iostream>

    struct y {};

    struct x: y {
        static const bool v = boost::is_base_of<y, x>::value;
    };

    int main() {
        std::cout << x::v << std::endl;
        return 0;
    }

$ g++ -Wall -Werror b00.cpp
/usr/include/boost/type_traits/is_base_and_derived.hpp: In
instantiation of ‘boost::detail::is_base_and_derived_impl2<y, x>’:
/usr/include/boost/type_traits/is_base_and_derived.hpp:219:
instantiated from ‘const bool
boost::detail::is_base_and_derived_impl<y, x>::value’
/usr/include/boost/type_traits/is_base_of.hpp:29: instantiated from
‘const bool boost::detail::is_base_of_imp<y, x>::value’
/usr/include/boost/type_traits/is_base_of.hpp:35: instantiated from
‘boost::is_base_of<y, x>’
b00.cpp:8: instantiated from here
/usr/include/boost/type_traits/is_base_and_derived.hpp:145: error:
invalid application of ‘sizeof’ to incomplete type ‘x’
/usr/include/boost/type_traits/is_base_and_derived.hpp:145: error:
invalid application of ‘sizeof’ to incomplete type
‘boost::STATIC_ASSERTION_FAILURE<false>’

$ g++ --version
g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thank you.

-- 
Lorenzo

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk