Title
Lvalue reference binding and function viability
Status
dup
Section
12.2.4.2.5 [over.ics.ref]
Submitter
Steve Clamage

Created on 2010-10-06.00:00:00 last changed 155 months ago

Messages

Date: 2010-11-15.00:00:00

Rationale (November, 2010):

This is a duplicate of issue 1152.

Date: 2022-11-20.07:54:16

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.)

History
Date User Action Args
2012-02-27 00:00:00adminsetmessages: + msg3858
2012-02-27 00:00:00adminsetstatus: open -> dup
2010-10-06 00:00:00admincreate