[Bug c++/13554] New: static_cast fails in Boost.Math library
john at johnmaddock dot co dot uk
gcc-bugzilla@gcc.gnu.org
Sat Jan 3 11:54:00 GMT 2004
I have a corner case where a static cast fails if the target type has an
explicit constructor, the case is abstacted from the Boost.Math library, and
compiles OK with VC++7.1 and EDG-frontend compilers, the failure seems to be a
regression from previous gcc releases:
namespace boost{
template<typename T, template<typename> class U>
U<T> test(const U<T>& t)
{
U<T> x = static_cast<U<T> >(1);
return t + x;
}
namespace nested{
template <class T>
struct numeric
{
numeric(){ m_value = 0; }
explicit numeric(T t){ m_value = t; }
T value()const { return m_value; }
private:
T m_value;
};
template <class T>
numeric<T> operator+(const numeric<T>& a, const numeric<T>& b)
{
return numeric<T>(a.value() + b.value());
}
}
}
int main()
{
boost::nested::numeric<double> num(2);
boost::test(num);
return 0;
}
--
Summary: static_cast fails in Boost.Math library
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: john at johnmaddock dot co dot uk
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13554
More information about the Gcc-bugs
mailing list