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
The definition of "reference-compatible" is not accurate #5239
Comments
The rules in [conv] explicitly define what "can be converted" means. [conv.qual]/3:
[conv.ptr]/3:
[conv.fctptr]/1:
The rules also say that in some cases the conversion is ill-formed, and what result you get, but the definition of "reference-compatible" doesn't talk about that. Given that both the definition and the use of the term use the same words "can be converted", I think there's no ambiguity in the intent here. However, we are requiring a reader to assume that "can be converted" for a standard conversion sequence is defined in terms of "can be converted" for its constituent conversions, which I don't think we actually say. And in particular the similar phrase "can be implicitly converted" is defined in [conv]/3 in a different way, that excludes the cases where a constituent conversion is ill-formed. Perhaps we could add a note that pointers can be converted even if the conversion would be ill-formed due to access or ambiguity? A cross-reference to the three different kinds of conversion that can be applied might be nice too:
|
@zygoloid I would expect that we can have formal rules that can eliminate these ambiguities. Since the ambiguities are not only in "reference-compatible" but also they exist in [over]. [over.best.ics.general] p1
Thus, whether the implicit conversion sequence can be formed is determined by [conv]/3, that is
However, I think it is not sufficient because the contradictories are produced by these two formal rules. Specifically, the contradictory was discussed in https://stackoverflow.com/questions/69326627/the-requirements-of-forming-an-implicit-conversion-sequence-are-contradictory |
Does "can be converted to ... via a standard conversion sequence" comprise the case: the standard conversion sequence does exist, however, due to some other requirement, the standard conversion so necessitates is ill-formed? Specifically, if we assume the definition of reference-compatible means that: if the standard conversion sequence is ill-formed, then “pointer to cv2 T2” cannot be converted to the type “pointer to cv1 T1”; consider this example
A
is reference-related toB
, thus each bullet that requires "T1 is not reference-related to T2" is skiped. With the above assumption,A
is not reference-compatible withB
, thus each bullet that requires “cv1 T1” is reference-compatible with “cv2 T2” is skiped. Eventually, the case falls into [dcl.init.ref] 5.4.2The implicit conversion is the call
A::A(A const&)
with the argumentb
, where the parameter binding to the argument is identical to the reference binding at#1
. This will cause the recursive inspection of the relevant bullets. Obviously, it's not the intent, the reference binding at#1
should be terminated at [dcl.init.ref] p4. That is,A
is reference-compatible withB
even if the standard conversion sequence is ill-formed due to inaccessibility. Maybe, we can improve the definition to be thatThe former is used to admit that
A
andB
are reference-compatible while the latter is used to negative the well-formed associated with the binding since the base classA
is inaccessible.The text was updated successfully, but these errors were encountered: