https://bugs.llvm.org/show_bug.cgi?id=51764

            Bug ID: 51764
           Summary: The explicit conversion function shouldn't be
                    considered in a model copy-initialization in reference
                    binding
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

struct D{};
D global;
struct A{
    explicit operator D(){
        return global;
    }
};
int main(){
    A a;
    D const& rf(a);
}

Clang is wrong to accept this example, as per [dcl.init.ref#5.4.1] 

> If T1 or T2 is a class type and T1 is not reference-related to T2, 
> user-defined conversions are considered using the rules for 
> copy-initialization of an object of type “cv1 T1” by user-defined conversion 
> ([dcl.init], [over.match.copy], [over.match.conv]); the program is ill-formed 
> if the corresponding non-reference copy-initialization would be ill-formed. 
> The result of the call to the conversion function, as described for the 
> non-reference copy-initialization, is then used to direct-initialize the 
> reference. For this direct-initialization, user-defined conversions are not 
> considered.  

In the copy-initialization of an object, the explicit conversion function is
not a candidate, hence the copy-initialization is ill-formed, hence the
reference binding is also ill-formed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to