以下の規格に適合していますか?セクションを引用できますか?
struct A
{
virtual void func() = 0;
};
struct B
{
void func(){}
};
struct C : public A, public B
{
virtual void func(){ B::func(); }
};
VS2010 で奇妙なコンパイラ警告が表示されますが、func
最も派生したクラスの の宣言を指しているより複雑なコードですwarning C4505: unreferenced local function has been removed
。クラスで宣言された仮想関数がローカルであるとコンパイラが考える理由がわかりません。ただし、より単純な例でその警告を再現することはできません。
編集:
警告の小さな再現ケースを見つけました。関数の隠蔽に関連していると仮定して、間違った道を進んでいたと思います。再現ケースは次のとおりです。
template<typename T>
struct C
{
int GetType() const;
virtual int func() const; // {return 4;} // Doing this inline removes the warning <--------------
};
template<typename T>
int C<T>::GetType() const
{
return 0;
}
template<>
int C<int>::GetType() const
{
return 12;
}
template<typename T>
int C<T>::func() const
{
return 3;
}
// Adding the following removes the warning <--------------------
// template<>
// int C<int>::func() const
// {
// return 4;
// }
これは単なる VS2010 のバグであると確信しています。