View Full Version : XCode Compiler warning: SemanticIssue - taking address of a temporary object...

08-14-2011, 09:44 PM
I should note that I'm using XCode 4. Yeah, I took the plunge :S

There are a lot of calls in your examples like this:


which gives me a compiler gripe,
taking address of a temporary object of type 'VariantList'"

This does seem like something that shouldn't be done - especially in games. Any suggestions for better practice passing VariantLists to a function like this?

08-14-2011, 09:53 PM
This code seems to get XCode to stop complaining:

VariantList v = VariantList(pBG);

But I'm still not convinced this is good practice...

08-15-2011, 12:14 AM
Yeah, GCC and some compilers have always warned about doing this, because, as I understand it, if the function called attempts to change the rvalue of the temporary object I'm sending, this is pointless at best and might not even be valid it say, it's an int that is only used in a register and never even given a real memory location.

However, I'm sending none POD data (not a simple datatype), and not ever trying to change the rvalue, so it in theory it is totally safe used the way I do and is just shorthand for the version you did it. I've never had a bug/crash related to doing that before.

That said, I've updated to xcode4 too - it's started labeling those in red like errors (but they still compile? confusing) so I've been sort of fixing them on my side too, to "get rid of the red".