I’m getting a compiler warning like this:
src\widgets\filehistory.cpp(92): warning C4172: returning address of local variable or temporary
which is the second return statement in GetHistoryFile():
const wxString &FileHistory::GetHistoryFile(size_t i) const
{
wxASSERT(i < mHistory.GetCount());
if (i < mHistory.GetCount()) {
return mHistory[i];
}
return wxEmptyString;
}
where wxEmptyString is:
extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxEmptyString;
Since wxEmptyString isn’t a wxString, a temporary is constructed and returned by reference. That temporary is destroyed when GetHistoryFile() returns.
This is probably not a good idea.