This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Implement -fsanitize=return (for C++ only)


On Fri, 22 Nov 2013, Marek Polacek wrote:

> On Fri, Nov 22, 2013 at 10:28:52AM +0100, Jakub Jelinek wrote:
> > Hi!
> > 
> > Working virtually out of Pago Pago right now.
> > 
> > In C++, falling through the end of a function that returns a value
> > without returning a value is undefined behavior (unlike C?), so this patch
> > implements instrumentation of it.
> 
> I think we really want to have this in for C99+ as well, mainly
> because C99 removed implicit int rule.

In C it's undefined behavior only if the caller uses the return value of a 
particular execution where the end of the called function was reached 
(6.9.1#12 in C11, "If the } that terminates a function is reached, and the 
value of the function call is used by the caller, the behavior is 
undefined.").

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]