Boost logo

Boost :

From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2002-08-30 11:06:07


Hi,

Partial specialization in the new GCC seems to be broken for
function types. This came up with LL, which triggered some warnings
in type_traits.

Here's a small test prgoram:

// -----------------------------------------

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

typedef void(T)(int); // T here is plain function type void()(),
boost::remove_cv<T>::type& f = foo;

int main() {};

// -----------------------------------------

And these are the error messages

/u/jajarvi/boost/boost/type_traits/cv_traits.hpp: In instantiation of
`boost::detail::cv_traits_imp<void (*)(int)>':
/u/jajarvi/boost/boost/type_traits/cv_traits.hpp:128: instantiated from
`boost::remove_cv<void ()(int)>'
type_traits.cpp:6: instantiated from here
/u/jajarvi/boost/boost/type_traits/cv_traits.hpp:73: warning: ignoring `
   volatile' qualifiers on `void ()(int)'
/u/jajarvi/boost/boost/type_traits/cv_traits.hpp:74: warning: ignoring `
   volatile' qualifiers on `void ()(int)'
/u/jajarvi/boost/boost/type_traits/cv_traits.hpp:72: warning: ignoring `
   volatile' qualifiers on `void ()(int)'
/u/jajarvi/boost/boost/type_traits/cv_traits.hpp:72: warning: ignoring `
   volatile' qualifiers on `void ()(int)'
/u/jajarvi/boost/boost/type_traits/cv_traits.hpp:75: warning: ignoring `
   volatile' qualifiers on `void ()(int)'
type_traits.cpp:6: `foo' was not declared in this scope

It seems that the compiler picks the wrong specialization for
cv_traits_imp (one with volatile qualifier).

Here is another test program to confirm this:

// --------------------------------------------------------
#include <iostream>

template <class T> class A {
public:
  static void foo () { std::cout << "Not volatile"; }
};

template <class T> class A<volatile T> {
public:
  static void foo () { std::cout << "Volatile"; }
};

template <class T>
void x(T& t) {
  A<T>::foo();
  // T here should be a plain function type int()()
  // The compiler (3.20) picks the specializatoin for A<volatile T> ???
}

int bar() {};

int main() {
  x(bar);
};

// ---------------------------------------------------------

Compiling the program with gcc3.2 gives similar warnings and when
executed, prints out "Volatile".

I've reported the bug to GNATS.

Any suggestions for a fix for type traits until it gets fixed?

Cheers, Jaakko


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