[binutils-gdb] [gdb/build] Fix Wnon-pod-varargs in bppy_repr

Tom de Vries via Gdb-cvs <[email protected]> Fri, 5 Jun 2026 21:03:47 +0000 (GMT)
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6ea05a29486718bc4aff5865761b657a8253a1c4

commit 6ea05a29486718bc4aff5865761b657a8253a1c4
Author: Tom de Vries <[email protected]>
Date:   Fri Jun 5 23:03:42 2026 +0200

    [gdb/build] Fix Wnon-pod-varargs in bppy_repr
    
    I build gdb with clang and ran into a build breaker:
    ...
    gdb/python/py-breakpoint.c:1074:52: error: cannot pass object of non-trivial \
      type 'const std::string' (aka 'const basic_string<char>') through variadic \
      function; call will abort at runtime [-Wnon-pod-varargs]
     1074 |     return PyUnicode_FromFormat ("<%s (invalid)>", tp_name);
          |                                                    ^
    ...
    
    This looks like fallout from commit dafd73bcda6 ("gdb/python: fix memory leak
    in gdb_py_tp_name"), which changed the return type of gdbpy_py_obj_tp_name
    from const char * to std::string.
    
    We could fix this using tp_name.c_str (), but instead fix this by simplifying
    the code using gdb_py_invalid_object_repr.
    
    Tested on x86_64-linux.
    
    Approved-By: Tom Tromey <[email protected]>

Diff:
---
 gdb/python/py-breakpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 30d5ea471c2..ecb42cee5f9 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -1071,7 +1071,7 @@ bppy_repr (PyObject *self)
 
   const auto bp = (struct gdbpy_breakpoint_object*) self;
   if (bp->bp == nullptr)
-    return PyUnicode_FromFormat ("<%s (invalid)>", tp_name);
+    return gdb_py_invalid_object_repr (self);
 
   std::string str = " ";
   if (bp->bp->thread != -1)