nullptr.cpp created this revision. nullptr.cpp requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
According to [dcl.init.ref]p5: > A reference to type “cv1 T1” is initialized by an expression of type “cv2 T2” > as follows: > > — If the reference is an lvalue reference and the initializer expression > — is an lvalue (but is not a bit-field), and “cv1 T1” is > reference-compatible with “cv2 T2”, or > — has a class type (i.e., T2 is a class type), where T1 is not > reference-related to T2, and can be converted to an lvalue of type > “cv3 T3”, where “cv1 T1” is reference-compatible with “cv3 T3” (this > conversion is selected by enumerating the applicable conversion > functions > and choosing the best one through overload resolution), > then the reference is bound to the initializer expression lvalue in the > first case and to the lvalue result of the conversion in the second case > (or, in either case, to the appropriate base class subobject of the > object). > > — Otherwise, [...] If the overload resolution fails in the second case, the program should continue to check other conditions and the program is NOT ill-formed at this point. But the code here sets the program to ill-formed state. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D93962 Files: clang/lib/Sema/SemaInit.cpp Index: clang/lib/Sema/SemaInit.cpp =================================================================== --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -4811,10 +4811,6 @@ /*IsLValueRef*/ isLValueRef, Sequence); if (ConvOvlResult == OR_Success) return; - if (ConvOvlResult != OR_No_Viable_Function) - Sequence.SetOverloadFailure( - InitializationSequence::FK_ReferenceInitOverloadFailed, - ConvOvlResult); } else { ConvOvlResult = OR_No_Viable_Function; }
Index: clang/lib/Sema/SemaInit.cpp =================================================================== --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -4811,10 +4811,6 @@ /*IsLValueRef*/ isLValueRef, Sequence); if (ConvOvlResult == OR_Success) return; - if (ConvOvlResult != OR_No_Viable_Function) - Sequence.SetOverloadFailure( - InitializationSequence::FK_ReferenceInitOverloadFailed, - ConvOvlResult); } else { ConvOvlResult = OR_No_Viable_Function; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits