GetTransform
returns something by-value, and you’re taking a pointer to that return value. That means you’re taking a pointer to a temporary that will immediately go out-of-scope.
It works in the second case since you’re keeping the value alive by copying/moving/eliding it into your copy, and then taking a pointer to that copy instead.