In GNU libiconv, I see these warnings:

../../srclib/careadlinkat.c:178:5: warning: #warning "GCC might issue a bogus 
-Wreturn-local-addr warning here." [-Wcpp]
../../srclib/careadlinkat.c:179:5: warning: #warning "See 
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93644>." [-Wcpp]
../../srclib/careadlinkat.c:182:10: warning: function may return address of 
local variable [-Wreturn-local-addr]

As noted in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93644#c19 ,
for GCC 12 or newer, the "#pragma GCC diagnostic ignored" succeeds in
silencing the warning. So let's use it.


2023-05-19  Bruno Haible  <br...@clisp.org>

        careadlinkat: Silence gcc warning for GCC ≥ 12.
        * lib/careadlinkat.c: For GCC 12 or newer, use
        "#pragma GCC diagnostic ignored" to silence the warning.

diff --git a/lib/careadlinkat.c b/lib/careadlinkat.c
index 359d497396..72c38e353e 100644
--- a/lib/careadlinkat.c
+++ b/lib/careadlinkat.c
@@ -55,7 +55,9 @@ enum { STACK_BUF_SIZE = 1024 };
    When the GCC bug is fixed this workaround should be limited to the
    broken GCC versions.  */
 #if _GL_GNUC_PREREQ (10, 1)
-# if defined GCC_LINT || defined lint
+# if _GL_GNUC_PREREQ (12, 1)
+#  pragma GCC diagnostic ignored "-Wreturn-local-addr"
+# elif defined GCC_LINT || defined lint
 __attribute__ ((__noinline__))
 # elif __OPTIMIZE__ && !__NO_INLINE__
 #  define GCC_BOGUS_WRETURN_LOCAL_ADDR




Reply via email to