Protect from comma operator overload

François Dumont frs.dumont@gmail.com
Tue Apr 17 20:34:00 GMT 2018


Yes, I also think there is no rush to fix this issue.

I had already written a test for a different purpose using the 
input_iterator_wrapper. This is why I detected this std::deque issue.

On 16/04/2018 22:16, Jonathan Wakely wrote:
> On 16 April 2018 at 21:08, Jonathan Wakely wrote:
>> On 16 April 2018 at 20:52, François Dumont wrote:
>>> Hi
>>>
>>>      While working on something else on libstdc++ I started having a test
>>> failing because of the missing comma overload protection in deque.tcc. So I
>>> looked for other similar places in the code and here is a patch to fix the
>>> places I found.
>>>
>>>      Let me know if it is still time to commit.
>> The changes look right, but please add new tests to demonstrate the
>> code that used to fail.
>>
>> You can use <testsuite_iterators.h> because the iterator types defined
>> in there have deleted comma operators that should cause errors in
>> these places.
> Something like this (but in four separate tests):
>
> #include <deque>
> #include <list>
> #include <vector>
> #include <testsuite_iterators.h>
>
> int main()
> {
>    using namespace __gnu_test;
>    int a[1] = {};
>    test_container<int, input_iterator_wrapper> t(a, a+1);
>
>    std::deque<int> d;
>    d.assign(t.begin(), t.end());
>
>    std::list<int> l;
>    l.assign(t.begin(), t.end());
>
>    std::vector<int> v;
>    v.assign(t.begin(), t.end());
>
>    std::vector<bool> b;
>    b.assign(t.begin(), t.end());
> }
>
>
> Given how rare it is for real code to overload the comma operator, and
> that nobody has reported these bugs, I think this can wait for after
> GCC 8.
>



More information about the Libstdc++ mailing list