unspecified

Undefined/Unspecified/Implementation-defined behaviour warnings?

Can't a compiler warn (even better if it throws errors) when it notices a statement with undefined/unspecified/implementation-defined behaviour? Probably to flag a statement as error, the standard should say so, but it can warn the coder at least. Is there any technical difficulties in implementing such an option? Or is it merely imposs...

Why is undefined behavior allowed (as opposed to not compiling/crashing)?

I understand the reasons for compiler/interpreter language extensions but why is behaviour that has no valid definition allowed to fail silently/do weird things rather then throwing a compiler error? Is it because of the extra difficulty(impossible or simply time consuming) for the compiler to catch them)? P.S. what languages have undef...

Function call in wrong order

This is what i have coded today #include <iostream> using namespace std; int function1() { cout<<"hello from function1()"; return 0; } int function2() { cout<<"hello from function2()"; return 0; } int main() { int func_diffresult = 0; func_diffresult = function1() - function2(); cout<<func_diffresult; /** prints 0 cor...