Skip to content

Conversation

stbergmann
Copy link
Contributor

...which avoids overload resolution ambiguities in C++20, when a synthesized
candidate of operator == for a reversed-argument rewrite conflicts with the
actual operator ==, due to the asymmetric const-ness of the implicit object
parameter and the RHS parameter. (As observed with recent Clang 10 trunk with
-std=c++2a when building firebird as part of LibreOffice:

workdir/UnpackedTarball/firebird/src/jrd/inf.cpp:1139:62: error: use of overloaded operator '!=' is ambiguous (with operand types 'RuntimeStatistics::Iterator' and 'Jrd::RuntimeStatistics::Iterator')
for (RuntimeStatistics::Iterator iter = stats.begin(); iter != stats.end(); ++iter)
~~~~ ^ ~~~~~~~~~~~
workdir/UnpackedTarball/firebird/src/jrd/../dsql/../jrd/RuntimeStatistics.h:283:8: note: candidate function
bool operator!=(const Iterator& other)
^
workdir/UnpackedTarball/firebird/src/jrd/../dsql/../jrd/RuntimeStatistics.h:278:8: note: candidate function
bool operator==(const Iterator& other)
^
workdir/UnpackedTarball/firebird/src/jrd/../dsql/../jrd/RuntimeStatistics.h:278:8: note: candidate function (with reversed parameter order)

)

...which avoids overload resolution ambiguities in C++20, when a synthesized
candidate of operator == for a reversed-argument rewrite conflicts with the
actual operator ==, due to the asymmetric const-ness of the implicit object
parameter and the RHS parameter.  (As observed with recent Clang 10 trunk with
-std=c++2a when building firebird as part of LibreOffice:

> workdir/UnpackedTarball/firebird/src/jrd/inf.cpp:1139:62: error: use of overloaded operator '!=' is ambiguous (with operand types 'RuntimeStatistics::Iterator' and 'Jrd::RuntimeStatistics::Iterator')
>         for (RuntimeStatistics::Iterator iter = stats.begin(); iter != stats.end(); ++iter)
>                                                                ~~~~ ^  ~~~~~~~~~~~
> workdir/UnpackedTarball/firebird/src/jrd/../dsql/../jrd/RuntimeStatistics.h:283:8: note: candidate function
>                 bool operator!=(const Iterator& other)
>                      ^
> workdir/UnpackedTarball/firebird/src/jrd/../dsql/../jrd/RuntimeStatistics.h:278:8: note: candidate function
>                 bool operator==(const Iterator& other)
>                      ^
> workdir/UnpackedTarball/firebird/src/jrd/../dsql/../jrd/RuntimeStatistics.h:278:8: note: candidate function (with reversed parameter order)

)
@asfernandes asfernandes merged commit 0ffbfdd into FirebirdSQL:master Oct 21, 2019
@stbergmann stbergmann deleted the c++20comparison branch October 22, 2019 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants