This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/65229] New: pretty-printer exception on std::bitset<0>
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 27 Feb 2015 00:12:04 +0000
- Subject: [Bug libstdc++/65229] New: pretty-printer exception on std::bitset<0>
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65229
Bug ID: 65229
Summary: pretty-printer exception on std::bitset<0>
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
The StdBitsetPrinter class assumes that objects of all std::bitset
specializations contain a member named _M_w. However, std::bitset<0> is an
empty class, and attempting to print an object of std::bitset<0> in GDB causes
a Python exception. A trivial patch to avoid the exception is below.
$ cat t.cpp && g++ -g t.cpp && gdb -batch -ex "b main" -ex r -ex "p b" -q a.out
#include <bitset>
int main (void) {
std::bitset<0> b;
(void)&b;
}
Breakpoint 1 at 0x4005b0: file t.cpp, line 4.
Breakpoint 1, main () at t.cpp:4
4 std::bitset<0> b;
Python Exception <class 'gdb.error'> There is no member or method named _M_w.:
$1 = std::bitset
index 5a414c5..8c5354f 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -568,7 +568,13 @@ class StdBitsetPrinter:
return '%s' % (self.typename)
def children (self):
- words = self.val['_M_w']
+ try:
+ # An empty bitset may not have any members which will
+ # result in an exception being thrown.
+ words = self.val['_M_w']
+ except:
+ return ""
+
wtype = words.type
# The _M_w member can be either an unsigned long, or an