[Bug libstdc++/21262] basic_string out_of_bound in constructor with null char in string
pcarlini at suse dot de
gcc-bugzilla@gcc.gnu.org
Thu Apr 28 09:26:00 GMT 2005
------- Additional Comments From pcarlini at suse dot de 2005-04-28 09:25 -------
There is nothing wrong with a null char per se. The problem is that you second
constructor call is wrong: according to the standard, there is *no* constructor
taking a const char*, and two size_type. Instead, there is one taking a string
and two size_type. Therefore, your str.data() is used to construct a temporary
string (only 6 char long, because the constructor taking a "C" string is used)
and then invoke the constructor mentioned above. Fix your code like this:
string str2(str, 10, str.size() - 10);
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21262
More information about the Gcc-bugs
mailing list