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:54:00 GMT 2019
On 19/06/19 21:49 +0200, Michael Weghorn wrote:
>Thank you for the quick reply!
>
>On 19/06/2019 21.37, Jonathan Wakely wrote:
>> 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'll do as soon as I plan to submit another patch.
>
>> 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.
>
>This sounds all reasonable, just one comment on the test:
>
>> + std::vector<bool> vb;
>> + vb.reserve(100);
>> + vb.push_back(true);
>> + vb.push_back(true);
>> + vb.push_back(false);
>> + vb.push_back(false);
>> + vb.push_back(true);
>> + vb.erase(vb.begin());
>> +// { dg-final { regexp-test vb {std::(__debug::)?vector of length 4, capacity 100 = \\{true, false, false, true\\}} } }
>> +
>
>This inserts 5 elements, so I'd expect that either "vector of length 5"
>and an additional "true" element at the beginning need to be added for
>the expected result or one of the two first 'vb.push_back(true)' needs
>to be removed.
It inserts five then erases one, the test is right.
Except that it should be capacity=128, because the capacity increases
in units of 64 bits. of course.
More information about the Gcc-patches
mailing list