From: Brian D. <sea...@ho...> - 2002-11-05 20:39:54
|
Greg Chicares <chi...@mi...> wrote: > Try posting a minimal self-contained example that > we can compile. Ok! Here's a "test.cpp"... 1: #include <memory> 2: 3: class BASE { int i; }; 4: 5: class DERIVED : public BASE { int j; }; 6: 7: void DoSomething(std::auto_ptr<BASE> pbase) { } 8: 9: int main() 10: { 11: std::auto_ptr<DERIVED> pderived (new DERIVED); 12: DoSomething(pderived); 13: } When I run gcc "test.cpp", this gets compiler errors: test.cpp: In function `int main()': test.cpp:12: no matching function for call to `std::auto_ptr<BASE>::auto_ptr(std::auto_ptr<BASE>)' D:/DEV/MINGW/include/c++/3.2/memory:346: candidates are: std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr_ref<_Tp>) [with _Tp = BASE] D:/DEV/MINGW/include/c++/3.2/memory:216: std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr<_Tp1>&) [with _Tp1 = BASE, _Tp = BASE] D:/DEV/MINGW/include/c++/3.2/memory:203: std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr<_Tp>&) [with _Tp = BASE] test.cpp:12: initializing temporary from result of `std::auto_ptr<_Tp>::operator std::auto_ptr<_Tp1>() [with _Tp1 = BASE, _Tp = DERIVED]' If I change the code to read: 9: int main() 10: { 11: std::auto_ptr<BASE> pderived (new DERIVED); 12: DoSomething(pderived); 13: } Then the compilation proceeds without these complaints. I do get some strange new errors regarding new/delete I don't recall having using the old gcc, though... C:\DOCUME~1\Brian\LOCALS~1\Temp/ccI1aaaa.o(.text+0x2e):test.cpp: undefined reference to `operator new(unsigned)' C:\DOCUME~1\Brian\LOCALS~1\Temp/ccI1aaaa.o (.text$_ZNSt8auto_ptrI4BASEED1Ev+0xf):test.cpp: undefined reference to `operator delete(void*)' C:\DOCUME~1\Brian\LOCALS~1\Temp/ccI1aaaa.o(.eh_frame+0x12):test.cpp: undefined reference to `__gxx_personality_v0' Make sense? Can anyone fix one (or, hey, both!) of these problems? ;) Thanks much! --- Brian Dickens http://phred.org/~brian _________________________________________________________________ Unlimited Internet access for only $21.95/month. Try MSN! http://resourcecenter.msn.com/access/plans/2monthsfree.asp |