https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98975
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note C and C++ are differ here. C says only if the return value is used it becomes undefined while in C++ it is undefined at the point of return.