PDA

View Full Version : Assertion failed when converting a std::string to std::basic_string<TCHAR> in debug



viet.nguyentien
13th December 2010, 03:06
The code is as follow:

std::basic_string<TCHAR> dest;
std::string source;

source = makesource(); //return a std::string value

#ifdef QT_DLL
dest = QString(source.c_str()).toStdWString(); //debug assertion failed here
#endif

When I build the project in release mode, everything is OK, but when I build in debug mode, the program crashed at the second line from the bottom.

Any suggestion will be appreciated.
Thank you for your time.

ChrisW67
13th December 2010, 09:09
It would help if you told us what the error message was and where the assert statement was. It would also help if you completely rebuilt your project to make sure this is not a mismatched binaries issue.

viet.nguyentien
17th December 2010, 09:26
Thanks ChrisW67 for your reply.

I gave up this one by redefining all the variables using std::string :)
My project is closed to the deadlines though.

Thanks for your time.