Florian Weimer writes: > --- > htdocs/gcc-14/porting_to.html | 46 ++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 43 insertions(+), 3 deletions(-) > > diff --git a/htdocs/gcc-14/porting_to.html b/htdocs/gcc-14/porting_to.html > index bbbaa25a..123b5e9f 100644 > --- a/htdocs/gcc-14/porting_to.html > +++ b/htdocs/gcc-14/porting_to.html > @@ -213,19 +213,59 @@ in functions which are declared to return void, or > return statements without expressions for functions > returning a non-void type. > > +

> +Both function definitions below contain -Wreturn-mismatch > +errors: > + > +

> +void
> +do_something (int flag)
> +{
> +  if (!flag)
> +    return -1;
> +  do_something_else ();
> +}
> +
> +int
> +unimplemented_function (void)
> +{
> +  puts ("unimplemented function foo called");
> +}
> +
> + > + >

> To address this, remove the incorrect expression (or turn it into a > statement expression immediately prior to the return > statements if the expression has side effects), or add a dummy return > -value, as appropriate. If there is no suitable dummy return value, > -further changes may be needed to implement appropriate error handling. > +value, as appropriate. > + > +

> +void
> +do_something (int flag)
> +{
> +  if (!flag)
> +    return -1;
> +  do_something_else ();
> +}
> +
> +int
> +unimplemented_function (void)
> +{
> +  puts ("unimplemented function foo called");
> +  return 0;
> +}
> +
> + > +If there is no suitable dummy return value, further changes may be > +needed to implement appropriate error handling. LGTM. > >

> Previously, these mismatches were diagnosed as > a -Wreturn-type warning. This warning still exists, and > is not treated as an error by default. It now covers remaining > potential correctness issues, such as reaching the closing > -brace } of function that does not > +brace } of a function that does not > return void. > >

> > base-commit: 5ef0adf3098478600f0c108e07e568d864b4c731