git: c2d4e8d4e9a7 - stable/14 - bsd.sys.mk: Disable -Wdangling-reference for GCC 13+

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 03 Jan 2024 17:50:02 UTC
The branch stable/14 has been updated by jhb:

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

commit c2d4e8d4e9a7b217e25fa9a20c560ed1e98ba236
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-11-15 02:35:04 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-01-03 17:43:48 +0000

    bsd.sys.mk: Disable -Wdangling-reference for GCC 13+
    
    GCC raises this warning for libc++'s istream.  It raises false
    positives in other cases as well (GCC bugs 109640, 109642, 109671).
    
    Warning from <istream>:
    
    /usr/include/c++/v1/istream:1464:34: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
     1464 |             const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
          |                                  ^~~~
    /usr/include/c++/v1/istream:1464:71: note: the temporary was destroyed at the end of the full expression 'std::__1::use_facet<ctype<char> >(std::__1::ios_base::getloc() const())'
     1464 |             const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
          |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
    
    Reviewed by:    imp, emaste
    Differential Revision:  https://reviews.freebsd.org/D42579
    
    (cherry picked from commit 28fc837b70372a1a99c28ef4f74325bce711960a)
---
 share/mk/bsd.sys.mk | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index 2b1a3e103b89..7d0e632973e4 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -234,6 +234,13 @@ CXXWARNFLAGS+=	-Wno-literal-suffix 			\
 		-Wno-error=unknown-pragmas
 .endif
 
+# GCC 13.1.0
+.if ${COMPILER_VERSION} >= 130100
+# These warnings are raised by headers in libc++ so are disabled
+# globally for all C++
+CXXWARNFLAGS+=	-Wno-dangling-reference
+.endif
+
 # GCC produces false positives for functions that switch on an
 # enum (GCC bug 87950)
 CWARNFLAGS+=	-Wno-return-type