https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111400
Bug ID: 111400 Summary: Missing return sanitization only works in C++ Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: david at westcontrol dot com Target Milestone: --- With C++ and -fsanitize=return, the code : int foo(void) { } generates a call to __ubsan_handle_missing_return. For C, there is no sanitizer call - just a simple "ret" instruction. This is, of course, because in C (unlike C++), falling off the end of a non-void function is legal and defined behaviour, as long as caller code does not try to use the non-existent return value. But just like in C++, it is almost certainly an error in the C code if control flow ever falls off the end of a non-void function. Could -fsanitize=return be added to C? It should not be included by -fsanitize=undefined in C, since the behaviour is actually allowed, but it would still be a useful option that could be enabled individually.