Access Violation error in String Constructor

std::string myString(iterator1, iterator2)

This piece of code works fine in VS2003 but not in VS2005. In the release mode (VS2005) it works fine. It says "Access Violation" in debug mode. Without using any macros is there a way we can avoid this "Access Violation" problem in debug mode? Any help is appreciated.
[321 byte] By [dnataraja] at [2007-11-20 6:30:02]
# 1 Re: Access Violation error in String Constructor
You really need to use the debugger to see what is going on. Somewhere it is referencing an invalid memory location. Even though it does not "blow up" in Release mode, it is very likely that the program will be unstable at best.
TheCPUWizard at 2007-11-9 1:16:09 >
# 2 Re: Access Violation error in String Constructor
std::string myString(iterator1, iterator2)

This piece of code works fine in VS2003 but not in VS2005. In the release mode (VS2005) it works fine. It says "Access Violation" in debug mode. Without using any macros is there a way we can avoid this "Access Violation" problem in debug mode? Any help is appreciated.What is "iterator1"? What is "iterator2"?

You need to show us a real code example that demonstrates the problem.

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-9 1:17:09 >
# 3 Re: Access Violation error in String Constructor
You really need to use the debugger to see what is going on. Somewhere it is referencing an invalid memory location. Even though it does not "blow up" in Release mode, it is very likely that the program will be unstable at best.The two argument constructor for std::string will exhibit undefined behaviour in one case -- where one of the arguments is NULL.

But unless the OP shows an example, then this is just speculation on my part.

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-9 1:18:16 >
# 4 Re: Access Violation error in String Constructor
The declaration of the Iterator1 and Iterator2 is as follows:

std::string::const_iterator Iterator1 ;
std::string::const_iterator Iterator2 ;
After assinging proper values to above variables, string constructor is called as follows:
std::string myString(Iterator1, Iterator2). Then the problem comes in debug mode.

Also the debugger shhows the problem at: _DEBUG_RANGE(_First, _Last);

And Finally it lands up at:

if (_Parent != 0 && _Parent->_Myfirstiter != _IGNORE_MYITERLIST)

Then there is a error message box depicting the access violation 0xffffff.

Please let me know in case you need more details.
dnataraja at 2007-11-9 1:19:13 >
# 5 Re: Access Violation error in String Constructor
The declaration of the Iterator1 and Iterator2 is as follows:

std::string::const_iterator Iterator1 ;
std::string::const_iterator Iterator2 ;
After assinging proper values to above variables, string constructor is called as follows:You still have not posted any program that demonstrates the error. Words and descripitions are not enough. We don't know what you assigned to Iterator1 or Iterator2.

Please follow the guidelines here:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8

Post a complete but minimal example that demonstrates the error.

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-9 1:20:10 >