bug in VC2005 compiler diagnostics

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

we met a curious bug in VC2005: the compiler understands correctly that a
class has no default constructor, thus it cannot generate a pair, but
strangely it makes the error point NOT to the class which causes the
problem, but (I think) to the first occurrence of that type in the file.
The following code (I think it could be simplified further) causes an error
which is tracked up to class SERIES, not to class CALCULATOR.



#include <utility>


template <typename T, int I>
struct no_def_ctor
{
no_def_ctor(int, int, int)
{
}

static no_def_ctor NA()
{
return no_def_ctor(0,0,0);
}

typedef std::pair< no_def_ctor<T, I>, double> pair_t;
};


template <typename T>
struct SERIES
{
typename T::pair_t member_;

SERIES()
: member_(T::NA(), 0)
{
}
};



template <typename T>
struct CALCULATOR
{
SERIES<T> ok_;
typename T::pair_t member_;

CALCULATOR() // should give error here: member_ has no default ctor
{
}
};






int main()
{

CALCULATOR< no_def_ctor<float, 1> > X;

return 0;
}






.



Relevant Pages