]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/build] Fix Wnon-pod-varargs in bppy_repr
authorTom de Vries <tdevries@suse.de>
Fri, 5 Jun 2026 21:03:42 +0000 (23:03 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 5 Jun 2026 21:03:42 +0000 (23:03 +0200)
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 <tom@tromey.com>
gdb/python/py-breakpoint.c

index 30d5ea471c2a433213f2b2d86579fb7872449b11..ecb42cee5f9195a39b7e757aa318f5040c5180cf 100644 (file)
@@ -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)