In your case, the return value of fun
is not void
, so, yes, it's undefined behavior.
C++11 6.6.3 The
return
statement[...] Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function.