[clang] [clang-cl] [Sema] Support MSVC non-const lvalue to user-defined temporary reference (PR #99833)
Max Winkler via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 11 23:51:18 PST 2024
================
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc %s -emit-llvm -fms-extensions -fms-compatibility -fms-reference-binding -Wno-microsoft-reference-binding -o - | FileCheck %s
+
+struct A {};
+struct B : A {};
+
+void fAPickConstRef(A&) {}
+void fAPickConstRef(const A&) {}
+
+void fBPickConstRef(A&) {}
+void fBPickConstRef(const A&) {}
+
+void fAPickRef(A&) {}
+void fAPickRef(const volatile A&) {}
+
+// NOTE: MSVC incorrectly picks the `const volatile A&` overload with the mangled name
----------------
MaxEW707 wrote:
https://godbolt.org/z/GvWY4n7rK
https://developercommunity.visualstudio.com/t/_MSC_VER--1940-MSVC-allows-binding-a/10811594
As noted in the comment this appears to be a bug in MSVC here as it also occurs during conforming reference binding. For clang we will continue to pick the `A&` overload when ms non-conforming reference binding is in use.
https://github.com/llvm/llvm-project/pull/99833
More information about the cfe-commits
mailing list