• Advertisement
Sign in to follow this  

std::string problem

This topic is 4648 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi anybody! I have problem with std::string container. I use guichan (http://guichan.sourceforge.net) and when I set new text for TextField, MSVS 6.0 said, that "breakpoint called at code ...", I don't use any breakpoint and i clear theirs for check. I tryed to find bug and it seems, that bug in std::string. I think i use it in wrong way. This is the code with bug:
std::string dir = dir_model->getElementAt(dir_list->getSelected());
if(dir != "..")
{
	if(path.size() > 3)
		path += '/' + dir; 
	 else path += dir;
}else
{
	path = findLastDir();
	path = cleanPath(path);
}
updateDirectories();
updateFiles();
//this is the code with bug
textfield->setText(std::string(path+"/"));
Can anyone tell what the bug is and how to fix it???

Share this post


Link to post
Share on other sites
Advertisement
You mean, "user breakpoint at ..." ?
That's an int3 instruction, probably put there by the compiler, in order to notify you somehow when you're calling to memory addresses not containing actual code.

It is probably a follow-up error. You could
- be using newer or older headers than a library/dll that is linked to your project
- drastically overwriting variables or arrays on the stack, corrupting things like the return address of a function call
- use a library or dll that has been created by a different compiler or uses another STL library (and thus, a different std::string variant)

This line probably does not do what you expect:
path += '/' + dir;

replace it with
path += std::string('/') + dir;


And the other std::string() copy here:
textfield->setText(std::string(path+"/"));

is not needed, making the line
textgield->setText(path + '/');


But no actual errors are in the code you've posted.

-Markus-

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement