Florian Weimer <fwei...@redhat.com> 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 > <code>void</code>, or > <code>return</code> statements without expressions for functions > returning a non-<code>void</code> type. > > +<p> > +Both function definitions below contain <code>-Wreturn-mismatch</code> > +errors: > + > +<pre> > +void > +do_something (int flag) > +{ > + if (!flag) > + return -1; > + do_something_else (); > +} > + > +int > +unimplemented_function (void) > +{ > + puts ("unimplemented function foo called"); > +} > +</pre> > + > + > <p> > To address this, remove the incorrect expression (or turn it into a > statement expression immediately prior to the <code>return</code> > 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. > + > +<pre> > +void > +do_something (int flag) > +{ > + if (!flag) > + return<del> -1</del>; > + do_something_else (); > +} > + > +int > +unimplemented_function (void) > +{ > + puts ("unimplemented function foo called"); > + <ins>return 0;</ins> > +} > +</pre> > + > +If there is no suitable dummy return value, further changes may be > +needed to implement appropriate error handling.
LGTM. > > <p> > Previously, these mismatches were diagnosed as > a <code>-Wreturn-type</code> 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 <code>}</code> of function that does not > +brace <code>}</code> of a function that does not > return <code>void</code>. > > <p> > > base-commit: 5ef0adf3098478600f0c108e07e568d864b4c731
signature.asc
Description: PGP signature