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 » Community » U++ community news and announcements » get_i
Re: get_i [message #54353 is a reply to message #54350] Fri, 03 July 2020 09:38 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14256
Registered: November 2005
Ultimate Member
Novo wrote on Thu, 02 July 2020 22:08
Sorry for the late response.
My code is correct. Temporary String lives only during function call. This is how C++ works.


I would not be fixing if it was correct. Whole thing was actual error in actual application.

Indeed, temp string lives only during function call. What happened here is that in some circustances when mixing String and const char * parameters, const char * gets converted to String temporary, then back to const char *, then temporary is detroyed and dangling const char * returned.

Quote:

Return type is a value, not a reference. So, no temporaries ...

And that is exactly the problem. That return value is temporary one level up and gets converted to const char *....

It is very tricky indeed. Actually the version posted here was not final, it needed more fixes for other situations (namely enums). Hopefully trunk version is now ok. Full test is in "autotest/decode". Also the error only appears with MSC, but I have checked, the problem is not in the compiler.

[Updated on: Fri, 03 July 2020 10:10]

Report message to a moderator

 
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: ide: Assist parsing now parallel and some of it background
Next Topic: 2020.1 officially released
Goto Forum:
  


Current Time: Wed Apr 30 01:07:51 CEST 2025

Total time taken to generate the page: 0.04323 seconds