I have some 'legacy' code (which I can't change, but need to add on to) that looks something like this:
template<typename T> T Foo(T& target)
{
//Assign to 'target', but never read from it before that.
//Also, 'target' is going to be a POD-type.
target = T();
return target;
}
int main()
{
float value = Foo(value);
}
This feels unsafe (i.e., making sure that target
is never assigned to before it's used), are there any other potentially lethal problems with this sort of interface?