Undefined behavior in C and C++