Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Other Features Wishlist and/or Bugs » bug in latest svn
Re: bug in latest svn [message #15683 is a reply to message #15681] Sun, 04 May 2008 17:14 Go to previous messageGo to previous message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
Novo wrote on Sun, 04 May 2008 17:04


const String& GetCppFile(int i);

String value1 = GetCppFile(0); // Case A
const String& value2 = GetCppFile(0); // Case B


In case A GetCppFile() will work correctly.
Case B will introduce a bug.

IMHO, returning "const String&" is just not thread-safe. Object can be deleted in transition.



I guess you're right, with your 2 examples.
On first example it 'should' work, because the source string isn't deleted before assignment, so the value is transferred. The secon example is buggy because you return a reference to an object that'll be deleted soon. BTW, I don't know how does the compiler behave with the const modifier.... but I guess it'll not solve the problem.

So the code is bad, imo.... is that maybe the problem ?

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: Mon May 13 17:41:20 CEST 2024

Total time taken to generate the page: 0.02129 seconds