visual c++ - C++ std::string Parameter is <Bad Ptr> -
i'm using visual studio 2010.
i have class following constructor:
cvideoannotation::cvideoannotation(std::string aport, dword abaudrate)
i create instance of cvideoannotation follows:
cvideoannotation cvideoannotation("com3", cbr_9600);
'cbr_9600' macro resolves 9600.
down in constructor, abaudrate 9600 expected. however, aport not passed properly. when hover cursor on it, intellisense gives value of <bad ptr>
.
does have thoughts on why string not pass properly?
thanks, dave
as update original question, i'm adding assembly code constructor call , population of locals once inside constructor.
cvideoannotation cvideoannotation("com3", cbr_9600); 0041177d push 2580h 00411782 sub esp,20h 00411785 mov ecx,esp 00411787 mov dword ptr [ebp-174h],esp 0041178d push offset string "com3" (4198c8h) 00411792 call std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> > (41131bh) 00411797 mov dword ptr [ebp-17ch],eax 0041179d lea ecx,[ebp-11h] 004117a0 call dword ptr [__imp_cvideoannotation::cvideoannotation (41d4dch)] 004117a6 mov dword ptr [ebp-180h],eax 004117ac mov dword ptr [ebp-4],0 cvideoannotation::cvideoannotation(std::string aport, dword abaudrate) { 100137f0 push ebp 100137f1 mov ebp,esp 100137f3 push 0ffffffffh 100137f5 push offset __ehhandler$??0cvideoannotation@@qae@v?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@k@z (1001dc82h) 100137fa mov eax,dword ptr fs:[00000000h] 10013800 push eax 10013801 sub esp,164h 10013807 push ebx 10013808 push esi 10013809 push edi 1001380a push ecx 1001380b lea edi,[ebp-170h] 10013811 mov ecx,59h 10013816 mov eax,0cccccccch 1001381b rep stos dword ptr es:[edi] 1001381d pop ecx 1001381e mov eax,dword ptr [___security_cookie (10026090h)] 10013823 xor eax,ebp 10013825 mov dword ptr [ebp-10h],eax 10013828 push eax 10013829 lea eax,[ebp-0ch] 1001382c mov dword ptr fs:[00000000h],eax 10013832 mov dword ptr [ebp-18h],ecx 10013835 mov dword ptr [ebp-84h],0 1001383f mov dword ptr [ebp-4],0
if implementing cvideoannotation in separate dll having know issue of crossing dll boundaries when using stl containers. verify case create new constructor taking const char* instead of std::string , try..
another thing, instead of std::string prefer use const std::string&
Comments
Post a Comment