Having just received a warning from the compiler for this function:
template<class T>
Matrix3x3<T> & operator - (Matrix3x3<T> const & p)
{
auto m = Matrix3x3<T>(p);
m.m11 = -m.m11; m.m12 = -m.m12; m.m13 = -m.m13;
m.m21 = -m.m21; m.m22 = -m.m22; m.m23 = -m.m23;
m.m31 = -m.m31; m.m32 = -m.m32; m.m33 = -m.m33;
return m;
}
, I am wondering why returning an address of local variable or temporary doesn't merit an error. Are there circumstances where you have to do it? What's the rationale for this only being "undefined behaviour" and not a language constraint?
I can't think of any.