I am trying to write code with expression templates that will permit me to perform operations on objects of different types, and I am trying to customize that behavior. For this purpose, it would be convenient for me if I could write a function such as:
double ReturnVal() {};
This code produces a compiler warning "no return statement in function returning non-void". But - the function appears to do what I want. Specifically, if I run:
double x = 5;
x = ReturnVal();
I find that x remains 5. It is unchanged by the function ReturnVal(). This is what I want the code to do.
I know this seems odd, but again, this would be useful because I am trying to write code with templates, and customizing the behavior of operators when they operate on similar (but different) types objects.
So, the question is - can I rely on this behavior that "x = ReturnVal()" doesn't change x? That's what I want, and it's what I am seeing gcc do in my testing. But I am nervous that this may be undefined behavior, and I can't rely on it.