doublemax wrote:this creates a pointer to a temporary object that is already invalid at the next line
I see! Thanks!
Your solution works, but I'm a bit confused as to how that behavior is even possible. Wouldn't any temporary object be destroyed when its scope is lost (which would be as soon as wc_str exits)? How could a temporary object pass a pointer to be dereferenced after its lifetime?
I'm not wording this well -- but like, if you call wc_str directly in the call to Format(), it seems to me that wc_str would end (and thus the temporary object would be destroyed) before Format is actually called.
Well whatever. Clarification would be nice, as that seems extremely strange to me, but I guess it isn't important.
Knowing this, though, I'll have to go back and double-check all my xx_str() function calls to make sure I'm not falling victim to this in other areas x_X
EDIT -
Unless... wxString doesn't really have a version of wc_str that returns const wchar_t* and it's instead casting the wxWCharBuffer to const wchar_t*. Then I guess that makes a whole lot of sense.
If that's the case, the documentation is VERY misleading.