Skip to content
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.general] p1 "T t = E;" determins whether the implicitly conversion sequenced can be formed #4934

Open
xmh0511 opened this issue Sep 24, 2021 · 2 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Sep 24, 2021

[over.best.ics.general] p1 says

An implicit conversion sequence is a sequence of conversions used to convert an argument in a function call to the type of the corresponding parameter of the function being called. The sequence of conversions is an implicit conversion as defined in [conv], which means it is governed by the rules for initialization of an object or reference by a single expression ([dcl.init], [dcl.init.ref]).

[over#best.ics.general-9] says

If no sequence of conversions can be found to convert an argument to a parameter type, an implicit conversion sequence cannot be formed.

[conv#general-3] says

An expression E can be implicitly converted to a type T if and only if the declaration T t=E; is well-formed, for some invented temporary variable t ([dcl.init]).

Consider this example

struct A{
  A(int) = delete;
};
struct B{
   B(int) {}
};
void fun(A);  //#1
void fun(B);  // #2
int main(){
    fun(0);  // #3
}

The intent of the rule is to make the call be ambiguous. However, according to [conv#general-3] says, since A t = 0; is ill-formed, hence we could say 0 cannot be implicitly converted to a type A, hence the implicit conversion sequence cannot be formed? #1 is not a viable function? Furthermore, for a parameter "lvalue reference to int", the argument is a bit-field of type int, according to [conv#general-3], it is also ill-formed except that [over.ics.ref#4] explicitly permits that

Other restrictions on binding a reference to a particular argument that are not based on the types of the reference and the argument do not affect the formation of an implicit conversion sequence, however.

I think these rules are contradictory.

@xmh0511 xmh0511 changed the title [over.best.ics.general] p1 "T t = E;" determin whether the implicitly conversion sequenced can be formed [over.best.ics.general] p1 "T t = E;" determins whether the implicitly conversion sequenced can be formed Sep 24, 2021
@xmh0511
Copy link
Contributor Author

xmh0511 commented Sep 25, 2021

@jensmaurer Could you please have a look at this issue.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Feb 21, 2023

cplusplus/CWG#246

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

No branches or pull requests

1 participant