[PATCH] Fix AIX build break.

Ciaran Woodward ciaranwoodward@xmos.com
Tue Feb 6 12:36:42 GMT 2024


> +/* A function that can be used to intercept warnings.  */
> +typedef void (*warning_hook_handler) (const char *, va_list);
> +
> +/* Set the thread-local warning hook, and restore the old value when
> +   finished.  */
> +class scoped_restore_warning_hook
> +{
> +public:
> +  explicit scoped_restore_warning_hook (warning_hook_handler new_handler);
> +
> +private:
> +  scoped_restore_tmpl<warning_hook_handler> m_save;
> +};

This part of the patch seems to have broken the build on mingw-64 gcc 13.2.0.

I think it is because va_list on that platform has some attributes.

Example (Werror) warning:

In file included from ../../gdb/defs.h:620,
                 from ../../gdb/x86-tdep.c:20:
../../gdb/utils.h:387:43: error: ignoring attributes on template argument 'warning_hook_handler' {aka 'void (*)(const char*, char*)'} [-Werror=ignored-attributes]
  387 |   scoped_restore_tmpl<warning_hook_handler> m_save;
      |                                           ^

I'm not sure what the 'best' solution is, as we don't really care about the
type attributes in this context, as we're just saving and restoring it.

I did have success with the following (pasted) patch, so I can submit that
properly if it isn't going to break anything for the AIX build, but also
open to other suggestions.

""""""
diff --git a/gdb/utils.c b/gdb/utils.c
index 702c3f15826..9d8a6443b37 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -145,7 +145,8 @@ get_warning_hook_handler ()

 scoped_restore_warning_hook::scoped_restore_warning_hook
      (warning_hook_handler new_handler)
-       : m_save (make_scoped_restore (&warning_hook, new_handler))
+       : m_save (make_scoped_restore (reinterpret_cast<void(**)()>(&warning_hook),
+                                      reinterpret_cast<void(*)()>(new_handler)))
 {
 }

diff --git a/gdb/utils.h b/gdb/utils.h
index 7487590902a..bea19369b9b 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -384,7 +384,7 @@ class scoped_restore_warning_hook
   explicit scoped_restore_warning_hook (warning_hook_handler new_handler);

 private:
-  scoped_restore_tmpl<warning_hook_handler> m_save;
+  scoped_restore_tmpl<void(*)()> m_save;
 };

 /* Return the current warning handler.  */
""""""

Cheers,
Ciaran


More information about the Gdb-patches mailing list