[C++-sig] problems with std::string (complete msg.)

jsseo jsseo at postech.ac.kr
Tue Dec 9 06:08:08 CET 2003


I'm sorry but the previous messages I sent were broken because of the
mailing system that I use.
Here is the original message.

When I passed a string parameter that is longer than 15,
the program hals with the following assertion failed error message.
The error occured when I built the project for "Debug" mode.
(compiler: Microsoft Visual Studio .NET 2003)

e.g. in python interpreter,
from ex1 import *
e = Ex("123456789012345") <-- ok
e = Ex("1234567890123456") <-- error
e.name = "123456789012345" <-- ok
e.name = "1234567890123456" <-- error

the error message
-----------------------------
Program:c:\python22\python.exe
File:dbgheap.c
Line: 1132
Expression: _CrtlsValidHeapPointer(pUserData)
-----------------------------

the follwing is the code.

file: idl.cpp
-----------------------------
BOOST_PYTHON_MODULE(ex1)
{
	class_("Ex1")
		.def(init())
		.add_property("name", &Ex1::getName, &Ex1::setName)
	;
}
-----------------------------

file: ex1.h
-----------------------------
class Ex1 {
public:
	Ex1() {};
	Ex1(std::string name);
	void setName(std::string name);
	...
};
-----------------------------

file:ex1.cpp
-----------------------------
Ex1::Ex1(std::string name) {
	this->name = name;
}
void Ex1::setName(std::string name) {
	this->name = name;
}
...
-----------------------------

Thanks in advance.

Jinseok Seo	






More information about the Cplusplus-sig mailing list