Protect from comma operator overload

François Dumont frs.dumont@gmail.com
Wed May 2 05:12:00 GMT 2018


Hi

     Here is the patch I eventually would like to commit.

     Tested under Linux x86_64, ok for trunk ?

François


On 17/04/2018 22:34, François Dumont wrote:
> 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.
>>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: comma_protect.patch
Type: text/x-patch
Size: 8128 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180502/4f962f2a/attachment.bin>


More information about the Gcc-patches mailing list