This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

ends?


I had a mistake in my program when I converted my program to use
ostringstream:

#include <iostream>
#include <sstream>

int main(int argc, char*argv[])
{
	int	number	= 4;
	ostringstream	ost;

	ost << "'String" << number << "'" << ends;	//oops.

	ostringstream	crudola;

	crudola << "this ";

	for (int i=0; i<ost.str().length(); ++i)
	{
		char	ch = ost.str()[i];

		switch (ch)
		{
		case '\'':
			crudola << "&quot;";
			break;

		default:
			crudola << ch;
		}
	}

	crudola << " that";

	cout << crudola.str();

	return 0;
}

This program prints: this &quot;String4&quot;

...omitting " that".  Should this happen?  I would prefer an assertion failure
or a crash to this, although I've since grepped my program for "ends" and
removed it everywhere.  I'm using gcc 2.95.2, libstdc++ 2.90.8 on Linux x86.

--
George T. Talbot
<george at moberg dot com>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]