Boost logo

Boost :

From: Christoph Ludwig (cludwig_at_[hidden])
Date: 2004-11-11 07:26:48


As I mentioned in previous posts the following code program

  #include <boost/type_traits/is_abstract.hpp>
  #include <iostream>

  template<typename T>
  struct A { virtual void f() = 0; }

  int main() {
    if(boost::is_abstract<A<int> >::value) {
      std::cout << "A<int> is abstract";
    else {
      std::cout << "A<int> is not abstract";
    }
  }

erroneously outputs "A<int> is not abstract" if compiled with gcc 3.4.

However, the regression tests report that gcc 3.4 passes the
is_abstract test. The reason is that above error is triggered only if
A<int> is not instantiated by the compiler; but is_abstract_test.cpp
does not test class template specializations at all.

This compiler bug cost me quite some time when my application showed
strange errors within the boost serialization library. Therefore, I'd
like to ensure that boost developers are aware of this issue so
similar problems can be avoided in the future. I thus propose to add
the attached test file to the type_trait regression tests.

The file is based on the existing is_abstract_test.cpp. My
contribution is merely that I turned all structs into templates and
that I added some extra tests w.r.t. explicit spezialization. I
therefore left the copyright statement as I found it in
is_abstract_test.cpp. If you add the file to the CVS, I leave it to
you whether you add my name there; I don't care much either way.

Regards

Christoph

-- 
http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/cludwig.html
LiDIA: http://www.informatik.tu-darmstadt.de/TI/LiDIA/Welcome.html



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