[libcxx] r217902 - Create a 'comma_iterator' class that overloads operator, and asserts when it's called. Add tests to mismatch to make sure it can't be blindsided by such an evil iterator. More tests for other algorithms forthcoming. Thanks to STL for pointing this out at CppCon and Yakov Galka for opening LWG issue #2133
dblaikie at gmail.com
Thu Oct 23 09:03:54 PDT 2014
On Wed, Oct 22, 2014 at 6:05 PM, Marshall Clow <mclow.lists at gmail.com>
> On Sep 16, 2014, at 2:13 PM, David Blaikie <dblaikie at gmail.com> wrote:
> On Tue, Sep 16, 2014 at 1:38 PM, Marshall Clow <mclow.lists at gmail.com>
>> Author: marshall
>> Date: Tue Sep 16 15:38:11 2014
>> New Revision: 217902
>> URL: http://llvm.org/viewvc/llvm-project?rev=217902&view=rev
>> Create a 'comma_iterator' class that overloads operator, and asserts when
>> it's called. Add tests to mismatch to make sure it can't be blindsided by
>> such an evil iterator. More tests for other algorithms forthcoming. Thanks
>> to STL for pointing this out at CppCon and Yakov Galka for opening LWG
>> issue #2133
> Could it use "= delete" to make this test fail at compile-time?
> Sorry I didn’t respond before.
> The point here is not that this should fail to compile, but rather that
> such evil iterators should work with the standard algorithms.
> See http://llvm.org/viewvc/llvm-project?rev=217903&view=rev for a change
> to std::mismatch to work correctly.
Right - but what I mean is if the definition was "= deleted" you'd get
compilation errors from the tests for std::mismatch before the (void) casts
were added, right? I figured it just might be a lower-cost way to test (not
needing to execute code) and give possibly easier to track down errors to
fix algorithms that weren't comma overload safe.
> — Marshall
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-commits