-
Notifications
You must be signed in to change notification settings - Fork 7
CWG2844 [over.match.oper] The algorithm for enumerating a finite set of built-in candidates is underspecified #362
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
Comments
Ugh, I realized that my suggested resolution doesn't actually work for other cases, such as |
It seems that the algorithm for how to enumerate a finite set of candidates must depend on which operand of each operator has an unbounded set of possible types and, if more than one such operand exists, the relationship between them. Here is a suggested resolution along those lines, also updated to cover the case of operands that are overload sets: [over.match.oper]/3.3 is unchanged. Insert a new paragraph after [over.built]/3:
Edit [over.built]/4:
Edit [over.built]/5:
Edit [over.built]/6:
Edit [over.built]/9:
Edit [over.built]/13, splitting it into two bullets:
Edit [over.built]/14:
Edit [over.built]/15. Note that there is a comma added after "enumeration type".
Edit [over.built]/16:
Edit [over.built]/19:
Edit [over.built]/20:
Edit [over.built]/21:
Edit [over.built]/25:
|
bump |
Why are we talking about conversions of the first operand of "operator=", although conversions are not allowed there? Why is operator?: in [over.builtin] at all, given that [expr.cond] describes the conversions rather clearly (and not quite like function parameter conversions to the same type). Also, operator?: cannot be overloaded to start with. |
IIUC these operator?: candidates are used only by [expr.cond]/6 to determine the conversions to be applied to the operands. |
Although For the |
OK, so here's what I was thinking of in my last comment: Merge [over.match.oper]/5 and [over.match.oper]/6 and make them into a note, with a cross-reference to [over.built]. In the first paragraph of the previous proposed wording, make the following change:
|
Full name of submitter: Brian Bi
Reference (section label): [over.match.oper]
Issue description: Consider the following example, which is accepted by Clang, but rejected by GCC:
The question is whether the implementation is required to find the built-in candidate
std::ptrdiff_t operator-(int*, int*)
, and select that candidate. The problem is that [over.built] specifies that there are an infinite number of built-in candidates, including one of the formstd::ptrdiff_t operator-(T*, T*)
for every object typeT
. If there are infinitely many built-in candidates, the implementation cannot iterate through all of them to determine whether each candidate is viable.One plausible approach is: look for non-template conversion functions in each operand of class type. If at least one operand yields a non-empty list of such non-template conversion functions, then consider the built-in candidates that have parameters of types that result from those conversion functions (or can be converted from one of those resulting types by a standard conversion). Under this approach, the code should be accepted. If this is the algorithm we want, we should specify it normatively so that GCC can also implement it.
[over.match.oper]/3.3 restricts the built-in candidate set to those that "accept operand types to which the given operand or operands can be converted according to [over.best.ics]". We can specify the algorithm normatively by restricting this set further.
Suggested resolution: Add a bullet before [over.match.oper]/3.3:
The text was updated successfully, but these errors were encountered: