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

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Sat, 30 Nov 2024 19:09:07 UTC
The branch stable/13 has been updated by jhb:

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

commit da72456591eee5b6bea590080a05f593b118a6a9
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-11-15 02:35:04 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-11-30 18:49:27 +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 d28bf09f2cb2..e537d7f045c4 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -243,6 +243,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