Fix compilation errors with C++20
In C++20 makes operator calls become ambiguous wrt to a rewritten version of itself with swapped candidates.
See https://gcc.godbolt.org/z/5q7GTr3bM for an example.
This commit fixes an occurence of this breakage in parent_index_iterator.h. Note that the actual breakage is in passes/Poppify.cpp that exposes the constraints of comparison operator for std::reverse_iteratot<Iterator>.
Thanks for the PR!
Hopefully someone that knows C++ better than me can take a look here, though this does seem safe to land.
+1 seems safe to land, but I would also like to understand this more. @ilya-biryukov, do you have a link to cppreference or even the spec that explains what's going wrong here?
The issue is that C++20 adds rewritten candidates with reversed parameters. These sometimes happen to be ambiguous with themselves.
In particular, in this case for operator ==(const Base*/*this*/, const Derived&) we additionally get a rewritten operator==(const Derived&, const Base*/*this*/). Since none of the two is more specialized if the arguments types are (Derived, Derived), the call happens to be ambiguous.
However, when sending the patch I was not aware that this is considered to be a defect in the C++ standard and there is a recently accepted proposal that fixes the issue for that particular code pattern.
The fix for Clang is on the way, so there is no need for this change. Although, I would still suggest to apply the same diff (maybe with a different description) as a best practice to make sure the types of both parameters of operator== are the same. That does not cause any immediate issues, though, so it's a purely stylistic suggestion.
Thanks for the additional context, @ilya-biryukov! I think using Iterator here is helpful for conveying that this is meant to be used with the CRTP subtype, so I'll close this PR, but thanks for the suggestion!
Landed as #5567
