[gcc(refs/vendors/ibm/heads/perf)] c++: Add test for DR 1423, Convertibility of nullptr to bool.
Jiu Fu Guo
guojiufu@gcc.gnu.org
Thu Mar 19 05:53:34 GMT 2020
https://gcc.gnu.org/g:b9934ad88d6b27e5cf1a34d88dbefb2bbe928753
commit b9934ad88d6b27e5cf1a34d88dbefb2bbe928753
Author: Marek Polacek <polacek@redhat.com>
Date: Mon Feb 24 12:56:00 2020 -0500
c++: Add test for DR 1423, Convertibility of nullptr to bool.
DR 1423, which supersedes DR 654, says that you can't copy-init
a bool from a std::nullptr_t:
bool b = nullptr; // error
Conversely, it works with direct-initialization which is more
permissive than copy-initialization.
No code changes necessary since we handle it right.
2020-02-26 Marek Polacek <polacek@redhat.com>
DR 1423, Convertibility of nullptr to bool.
* g++.dg/DRs/dr1423.C: New test.
Diff:
---
gcc/testsuite/ChangeLog | 5 +++++
gcc/testsuite/g++.dg/DRs/dr1423.C | 7 +++++++
2 files changed, 12 insertions(+)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4f46c385403..a18b1f2ef89 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-26 Marek Polacek <polacek@redhat.com>
+
+ DR 1423, Convertibility of nullptr to bool.
+ * g++.dg/DRs/dr1423.C: New test.
+
2020-02-26 Marek Polacek <polacek@redhat.com>
PR c++/93803 - ICE with constexpr init and [[no_unique_address]].
diff --git a/gcc/testsuite/g++.dg/DRs/dr1423.C b/gcc/testsuite/g++.dg/DRs/dr1423.C
new file mode 100644
index 00000000000..d82baae9985
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr1423.C
@@ -0,0 +1,7 @@
+// DR 1423 - Convertibility of nullptr to bool.
+// { dg-do compile { target c++11 } }
+
+bool b = nullptr; // { dg-error "converting to .bool. from .std::nullptr_t. requires direct-initialization" }
+bool b2(nullptr);
+bool b3{nullptr};
+bool b4 = { nullptr }; // { dg-error "converting to .bool. from .std::nullptr_t. requires direct-initialization" }
More information about the Gcc-cvs
mailing list