return-value policy question

Benjamin Kosnik bkoz@redhat.com
Tue Apr 29 15:54:00 GMT 2003


>Frankly, I can't find in what the second version is simpler and more
>elegant.  The former compute the value to return in either branches,
>and in a single return-statement returns the computed value.  
>
>Having -- recently -- to monitor return-statements in the compiler I
>found it  
>
>  * astonishingly helfpul that functions that span may pages have a
>    single return statement and very easy to monitor;
>
>  * functions that had many return-statements were the ones that
>    provided many opportunities for having the auditing worng;
>
>  * the functions with a single return-statement are no harder to
>    read (actually it was the functions with many return-statements
>    that were harder to read).
>
>[...]

100% agreed. Nathan, try stepping through this in gdb.

In addition, for complex types, this enforces NRV. 

-benjamin



More information about the Libstdc++ mailing list