Skip to content

[libc++][test] Do not test Clang bug in is_constructible.pass.cpp #105964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2024

Conversation

cpplearner
Copy link
Contributor

A comment in is_constructible.pass.cpp suggests that Clang is non-conforming in accepting construction of const int& from ExplicitTo<int&&>.

// Binding through reference-compatible type is required to perform
// direct-initialization as described in [over.match.ref] p. 1 b. 1:
//
// But the rvalue to lvalue reference binding isn't allowed according to
// [over.match.ref] despite Clang accepting it.

This PR changes the test to expect the standard-conforming behavior, which makes the test pass on MSVC.

@cpplearner cpplearner requested a review from a team as a code owner August 25, 2024 01:34
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Aug 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 25, 2024

@llvm/pr-subscribers-libcxx

Author: S. B. Tam (cpplearner)

Changes

A comment in is_constructible.pass.cpp suggests that Clang is non-conforming in accepting construction of const int&amp; from ExplicitTo&lt;int&amp;&amp;&gt;.

// Binding through reference-compatible type is required to perform
// direct-initialization as described in [over.match.ref] p. 1 b. 1:
//
// But the rvalue to lvalue reference binding isn't allowed according to
// [over.match.ref] despite Clang accepting it.

This PR changes the test to expect the standard-conforming behavior, which makes the test pass on MSVC.


Full diff: https://github.com/llvm/llvm-project/pull/105964.diff

1 Files Affected:

  • (modified) libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp (+2-2)
diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
index 578efb90f7f1ab..9f1bb50e76dc97 100644
--- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
@@ -228,8 +228,8 @@ int main(int, char**)
     // But the rvalue to lvalue reference binding isn't allowed according to
     // [over.match.ref] despite Clang accepting it.
     test_is_constructible<int&, ExplicitTo<int&>>();
-#ifndef TEST_COMPILER_GCC
-    test_is_constructible<const int&, ExplicitTo<int&&>>();
+#ifndef __clang__
+    test_is_not_constructible<const int&, ExplicitTo<int&&>>();
 #endif
 
     static_assert(std::is_constructible<int&&, ExplicitTo<int&&>>::value, "");

Copy link

github-actions bot commented Aug 25, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 3ef64f7ab5b8651eab500cd944984379fce5f639 803712c89a3c25cec4890f6b1e4c3f776c414ade --extensions cpp -- libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
View the diff from clang-format here.
diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
index 9a5efe7b5f..835a736f64 100644
--- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
@@ -228,9 +228,9 @@ int main(int, char**)
     // But the rvalue to lvalue reference binding isn't allowed according to
     // [over.match.ref] despite Clang accepting it.
     test_is_constructible<int&, ExplicitTo<int&>>();
-#ifndef TEST_COMPILER_CLANG
+#  ifndef TEST_COMPILER_CLANG
     test_is_not_constructible<const int&, ExplicitTo<int&&>>();
-#endif
+#  endif
 
     static_assert(std::is_constructible<int&&, ExplicitTo<int&&>>::value, "");
 

@ldionne ldionne merged commit 499e135 into llvm:main Aug 26, 2024
8 of 11 checks passed
@cpplearner cpplearner deleted the is-not-constructible branch August 27, 2024 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants