Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jul 2026 10:00:35 +0000
From:      Olivier Certner <olce@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Cc:        Lexi Winter <lexi@hemlock.eden.le-fay.org>
Subject:   git: a00d53218a09 - stable/14 - style.9: relax "return (value)" requirement for C++
Message-ID:  <6a61e643.3cabd.63c72cb4@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=a00d53218a0998aa083789af8b37c76af8dbf34c

commit a00d53218a0998aa083789af8b37c76af8dbf34c
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-03-27 14:23:13 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-07-23 09:59:03 +0000

    style.9: relax "return (value)" requirement for C++
    
    consider the following C++ code:
    
            struct S { int a, b; };
            S f() { return {1, 2}; }
    
    according to style(9), the return statement should be formatted as:
    
            return ({1, 2});
    
    however, this is not valid C++ code and will not compile.
    
    add an exception to style(9) to cover this case.
    
    Reviewed by: imp, emaste
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1623
    Closes: https://github.com/freebsd/freebsd-src/pull/1623
    
    (cherry picked from commit daf47b9ec9ed360dfdff6769ae4d0c2c16972552)
---
 share/man/man9/style.9 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/share/man/man9/style.9 b/share/man/man9/style.9
index 5542a9685c46..484b4f144b2e 100644
--- a/share/man/man9/style.9
+++ b/share/man/man9/style.9
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd February 18, 2025
+.Dd March 27, 2025
 .Dt STYLE 9
 .Os
 .Sh NAME
@@ -766,7 +766,8 @@ to any pointer type.
 .Pp
 Values in
 .Ic return
-statements should be enclosed in parentheses.
+statements should be enclosed in parentheses where possible.
+For example, parentheses cannot be used if the value is a C++ braced-init-list.
 .Pp
 Use
 .Xr err 3


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a61e643.3cabd.63c72cb4>