New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[over.best.ics] Disambiguating ambiguous conversion sequences (again) #3978
Comments
For your first example, there is implementation divergence: https://godbolt.org/z/wYskLe All compilers agree that the second example is well-formed. I fail to find a rule that would prefer int -> A over int -> long -> A, though. [over.ics.rank] p3.3 only applies if the same constructor of A would be called for both sequences. |
@jensmaurer Ah, I forgot to mention that this was motivated by the implementation divergence (clang fails to disambiguate when it should).
[over.ics.rank] p3.3 doesn't apply here since the initialization copy initialization of |
Agreed for the second example. For the first example, "of the same form" in over.ics.rank p3 first sentence refers to standard/user-defined/ellipsis (the "basic form" mentioned in p2). We have already established that the ambiguous conversion sequence is a user-defined conversion sequence ([over.best.ics] p10), so this particular condition is already satisfied. |
In my example, I think we want over.ics.rank p3.1.1 to apply here, making the |
Given the example in over.best.ics p10 (first case) and the existing text, I'm not seeing any editorial leeway here. |
In #2288 we attempted to clarify ambiguous conversion sequences, but I think there are a couple problems left unaddressed.
Consider the following:
[over.best.ics] p10 says:
In the above example, the ICS from
{0}
toC
is the ambiguous conversion sequence (ACS) and the ICS from{0}
tostd::initializer_list<A>
is a user-defined conversion sequence (UCS). Now with respect to the quoted paragraph: is the ACS considered to be indistinguishable from any other UCS regardless of [over.ics.rank], or will the rules in [over.ics.rank] p3 apply to disambiguate in this situation, making the conversion tostd::initializer_list<A>
a better ICS? I think the intent is pretty clear that the latter is true, but the wording does not make this clear.For this issue, I think the following change would be sufficient:
Change [over.best.ics] p10 sentence 2:
As for the other issue, consider the first sentence of [over.best.ics] p10:
First off, this wording seems to be at odds with the note in [over.best.ics] p2, particularly with the "well-formed" bit which I take to say that the application of that sequence of conversions must be be well-formed, most notably with respect to access control and whether a function is deleted. In addition to this, it's unclear what it even means for there to be multiple implicit conversion sequences. For example:
Arguably, there are "multiple well-formed implicit conversion sequences" here, both of which are user-defined conversion sequences. Here the intent is obvious as to what should occur.
There are two ways to approach this: either a substantial overhaul as to how we chose the ICS for a particular function parameter, or a smaller scale patch. For the latter, I suggest the following:
Change [over.best.ics] p10 sentence 1:
As for the more substantial change, it would entail forming a set of candidate conversion sequences from each argument to its respective parameter in each applicable subclause, and then determining if the resultant conversion from the argument to the parameter is either formed, not formed, or ambiguous.
The text was updated successfully, but these errors were encountered: