bug in VC2005 compiler diagnostics
- From: "Mycroft Holmes" <m.holmes@xxxxxxxxx>
- Date: Fri, 17 Nov 2006 16:39:01 +0100
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;
}
.
- Follow-Ups:
- Re: bug in VC2005 compiler diagnostics
- From: Tim Roberts
- Re: bug in VC2005 compiler diagnostics
- Prev by Date: Re: Problem with cryptoapi
- Next by Date: Re: Bug in VC++ 7.1?
- Previous by thread: ShoutDown Event
- Next by thread: Re: bug in VC2005 compiler diagnostics
- Index(es):
Relevant Pages
|