Boost logo

Boost :

Subject: [boost] is_base_of: bug in trunk, not in sandbox
From: Frédéric Bron (frederic.bron_at_[hidden])
Date: 2011-03-10 07:54:46


Thanks to Christopher Jefferson, I discovered a bug in the trunk (in
fact in 1.46.0) for is_base_of in the type_traits library.

is_base_of<int, int>::value should be true according to the doc:
"is_base_of<Base, Base>::value is an integral constant expression that
evaluates to true: a class is regarded as it's own base.

However the following program prints 0 and not 1 with g++ 4.4.5 on linux:

#include <boost/type_traits/is_base_of.hpp>
#include <iostream>
int main() {
        std::cout<<::boost::is_base_of<int, int>::value<<'\n';
        return 0;
}

Using the sandbox version of is_base_of works just fine. This makes my
type trait extension fail on 6 tests when using only the trunk (for
the 6 comparison operators).
I have a workaround for my extension which is to add "or is_same<T,
U>" but it would be better if is_base_of would work correctly.

Frédéric


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