On Wed, Nov 2, 2011 at 12:59 PM, Igor Tandetnik <itandet...@mvps.org> wrote:
> The behavior of this fragment is in fact well defined by the C++ standard. > The temporary is destroyed at the end of the full expression - basically, > at the semicolon, after the function call > That was also my understanding until recently when a friend of mine asked me to debug some code of his which mysteriously crashed. It was caused by a Qt debug wrapper macro which did the equivalent of c_str() on a temporary string instance. i unfortunately don't have the docs handy, and to be honest i'm not 100% convinced that what i wrote about undefined behaviour is true in that case, but i am 100% convinced that i've seen that usage cause problems before. Perhaps it was the compiler in question (one of the MSVC variants) which made the behaviour undefined, as opposed to be a violation of the standard. In any case (undefined or not), calling ostringstream::str() twice there is unnecessary, and downright inefficient if the user's STL does not use CoW (all of them do, AFAIK, but that's an implementation detail clients shouldn't count on). -- ----- stephan beal http://wanderinghorse.net/home/stephan/ _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users