U++ framework
Do not panic. Ask here before giving up.

Home » U++ TheIDE » U++ TheIDE: Other Features Wishlist and/or Bugs » bug in latest svn
Re: bug in latest svn [message #15679 is a reply to message #15673] Sun, 04 May 2008 12:17 Go to previous messageGo to previous message
mdelfede is currently offline  mdelfede
Messages: 1313
Registered: September 2007
Ultimate Contributor
Novo wrote on Sun, 04 May 2008 03:35

mdelfede wrote on Sat, 03 May 2008 13:17


AFAIK that's a right behavior, as returned temporary string is firs assigned to result and then deleted.



IMHO, the way you describe would work if the function looks like below.

String GetCppFile(int i);



Current implementation is similar to code below.

const String* GetCppFile(int i)
{
	INTERLOCKED_(cpp_file_mutex) {
		return &cpp_file[i];
	}
	return &String();
}


Does this look correct to you?



Nope, I guess... here you're returning a reference to a local variable, that can (and usually IS) destroyed BEFORE function returns. So, you could make it static to solve the problem, but then you'd have many other problems, in particular with MT.
Returning a String() value is less efficient, but guarantees that string is not destroyed on function return before the value is taken.

Max

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Some lack of features
Next Topic: [BUG] Ide loses "maximized" setting on minimize
Goto Forum:
  


Current Time: Sun Oct 04 18:23:12 GMT+2 2026

Total time taken to generate the page: 0.01349 seconds