2011-08-30 2 views
2

/Wall으로 컴파일 중이며 경고가 C4100: 'ptr' : unreferenced formal parameter warning이됩니다. 이 경고는 기본 소멸자가있는 MSVC의 std::_Container_proxy에서 소멸자를 호출하여 발생하는 것으로 보입니다.POD의 기본 소멸자가 정적입니까?

내 코드 :

template<class T> 
class linear_allocator { 
    //...other declarations... 
    static void destroy(pointer ptr); 
}; 
//...other definitions... 
template<class T> 
inline void linear_allocator<T>::destroy(typename linear_allocator<T>::pointer ptr) 
{ 
    ptr->~T(); //line 262. warning C4100: 'ptr' : unreferenced formal parameter 
} 
//ironically, this isn't a test case, this is my actual thingy class. Go figure. 
struct thingy { 
    unsigned int DATA; 
    thingy() : DATA(0xABCDEF) {} 
    ~thingy() {assert(DATA == 0xABCDEF);} 
}; 
int main() { 
    typedef std::vector<thingy, linear_allocator<thingy>> thingyholder; 
    std::vector<thingyholder> holder; 
} 

경고의 전문은 다음과 같습니다

 f:\code\utilities\linear_allocator\linear_allocator.h(261): warning C4100: 'ptr' : unreferenced formal parameter 
     f:\code\utilities\linear_allocator\linear_allocator.h(262) : while compiling class template member function 'void linear_allocator<T>::destroy(std::_Container_proxy *)' 
     with 
     [ 
      T=std::_Container_proxy 
     ] 
     f:\code\utilities\linear_allocator\linear_allocator.h(178) : while compiling class template member function 'linear_allocator<T>::~linear_allocator(void) throw()' 
     with 
     [ 
      T=std::_Container_proxy 
     ] 
     c:\program files\microsoft visual studio 10.0\vc\include\vector(454) : see reference to class template instantiation 'linear_allocator<T>' being compiled 
     with 
     [ 
      T=std::_Container_proxy 
     ] 
     c:\program files\microsoft visual studio 10.0\vc\include\vector(452) : while compiling class template member function 'std::_Vector_val<_Ty,_Alloc>::~_Vector_val(void)' 
     with 
     [ 
      _Ty=thingy, 
      _Alloc=linear_allocator<thingy> 
     ] 
     c:\program files\microsoft visual studio 10.0\vc\include\vector(481) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled 
     with 
     [ 
      _Ty=thingy, 
      _Alloc=linear_allocator<thingy> 
     ] 
     c:\program files\microsoft visual studio 10.0\vc\include\vector(1307) : see reference to class template instantiation 'std::vector<_Ty,_Ax>' being compiled 
     with 
     [ 
      _Ty=thingy, 
      _Ax=linear_allocator<thingy> 
     ] 
     c:\program files\microsoft visual studio 10.0\vc\include\vector(1301) : while compiling class template member function 'void std::vector<_Ty>::_Tidy(void)' 
     with 
     [ 
      _Ty=thingyholder 
     ] 
     f:\code\utilities\linear_allocator\main.cpp(71) : see reference to class template instantiation 'std::vector<_Ty>' being compiled 
     with 
     [ 
      _Ty=thingyholder 
     ] 

나는 그것이 단순히 std::_Container_proxy의 소멸자, 사용하고 있음을 참조하십시오

struct _Container_proxy 
{ // store head of iterator chain and back pointer 
_Container_proxy() 
    : _Mycont(0), _Myfirstiter(0) 
    { // construct from pointers 
    } 

const _Container_base12 *_Mycont; 
_Iterator_base12 *_Myfirstiter; 
}; 

MSVC C4100: 'application' : unreferenced formal parameter warning에 따르면 if The functions you are calling using the application object are static functions, so they aren't really referencing the application object.이 발생합니다. std::_Container_proxy은 POD 인 것처럼 보입니까? 그렇다면 기본 소멸자가 정적으로 최적화 된 것입니까?

는 (. 예, 내가 ptr=ptr; //warning workaround에 넣어 전에 내가 경고를 받고 있어요 왜해야 할 경고가 멀리 갈 수 있도록 다양한 해결 방법을 알고있다.)

+0

"소멸자"입니다. –

+0

나는 거의 모든 곳에서 생성자를 썼고 혼란스러워했다. –

+0

직장에서의 제 코드에는 오디오 "propmts"에 대한 언급에서 많은 언급이 있습니다. –

답변

관련 문제