public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111400] New: Missing return sanitization only works in C++
@ 2023-09-13  7:58 david at westcontrol dot com
  2023-09-13  9:19 ` [Bug c/111400] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: david at westcontrol dot com @ 2023-09-13  7:58 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-12-01  8:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-13  7:58 [Bug c/111400] New: Missing return sanitization only works in C++ david at westcontrol dot com
2023-09-13  9:19 ` [Bug c/111400] " rguenth at gcc dot gnu.org
2023-09-13  9:36 ` david at westcontrol dot com
2023-09-13  9:42 ` schwab@linux-m68k.org
2023-09-13 10:28 ` david at westcontrol dot com
2023-09-13 16:22 ` pinskia at gcc dot gnu.org
2023-12-01  8:42 ` sjames at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).