This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


1205. Lvalue reference binding and function viability

Section: 12.2.4.2.5  [over.ics.ref]     Status: dup     Submitter: Steve Clamage     Date: 2010-10-06

According to 12.2.4.2.5 [over.ics.ref] paragraph 3,

Except for an implicit object parameter, for which see 12.2.2 [over.match.funcs], a standard conversion sequence cannot be formed if it requires binding an lvalue reference to non-const to an rvalue or binding an rvalue reference to an lvalue.

This isn't precisely the restriction placed by 9.4.4 [dcl.init.ref] on binding an lvalue reference to an rvalue; the requirement there is that the cv-qualification must be exactly const in such cases. This has an impact on the interpretation of the following example:

    void f(const volatile int&);
    void f(...);
    void g() {
        f(1);
    }

Because f(const volatile int&) is considered a viable function for the call, it is a better match than f(...), but the binding of the argument to the parameter cannot be done, so the program is ill-formed. Presumably “lvalue reference to non-const” should be clarified to exclude the const volatile case. (Implementations vary on their handling of this example.)

Rationale (November, 2010):

This is a duplicate of issue 1152.