PR libstdc++/90945 Patch to have pretty printer for std::vector<bool> return bool intead of int for elements
Jonathan Wakely
jwakely@redhat.com
Wed Jun 19 19:37:00 GMT 2019
On 19/06/19 19:04 +0200, Michael Weghorn wrote:
>Hi everyone,
>
>the Python pretty printer for a 'std::vector<bool>' currently returns
>integers as values for the elements, which e.g. leads to the situation
>that a 'gdb.Value' constructed from that doesn't have 'bool' type, but
>an integer type ('long long' for my test with gdb 8.2.1 on Debian
>testing, amd64). Returning bool values ('True'/'False') would make sure
>that the type is clear and can thus help improve the displayed type.
>More details in [1].
>
>The attached patch changes the behaviour of the pretty printer accordingly.
>
>
>I'd be glad to receive feedback on this and also notes in case anything
>else is needed. (This is my first contribution.)
Thanks, the patch looks fine and is small enough that we can accept it
without a copyright assignment, but if you plan to contribute again
you should look into https://gcc.gnu.org/contribute.html#legal
I think I'd prefer to have the 'elt' variable be the actual element
(not the unsigned long that contains the element) so I'll adjust the
patch to do this instead:
elt = bool(self.item.dereference() & (1 << self.so))
>So far, I've tested this with GDB 8.2.1 on Debian testing.
It looks like we don't have any tests in the testsuite for printing
vector<bool>, so I'll add one to verify this behaviour and commit your
patch - thanks!
I've attached what I'm testing and plan to commit.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 3538 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190619/6ac9c837/attachment.bin>
More information about the Libstdc++
mailing list