diff mbox series

[C++] PR c++/87093

Message ID CAFk2RUY6vasM8j2PYwbs1bbWOE_cG72X3pjmySF53Wy4vNiWwg@mail.gmail.com
State New
Headers show
Series [C++] PR c++/87093 | expand

Commit Message

Ville Voutilainen Sept. 9, 2018, 10:02 p.m. UTC
Tested manually on Linux-x64, running full suite on Linux-PPC64. This
seems half-obvious. OK for trunk? Backports?

2018-09-10  Ville Voutilainen  <ville.voutilainen@gmail.com>

    gcc/cp

     PR c++/87093
    * method.c (constructible_expr): We're in an unevaluated context
    in all cases, not just for class targets.

    testsuite/

     PR c++/87093
    * g++.dg/ext/is_constructible2.C: New.

Comments

Jason Merrill Sept. 9, 2018, 11:26 p.m. UTC | #1
OK for trunk and branches.

On Sun, Sep 9, 2018 at 11:02 PM, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
> Tested manually on Linux-x64, running full suite on Linux-PPC64. This
> seems half-obvious. OK for trunk? Backports?
>
> 2018-09-10  Ville Voutilainen  <ville.voutilainen@gmail.com>
>
>     gcc/cp
>
>      PR c++/87093
>     * method.c (constructible_expr): We're in an unevaluated context
>     in all cases, not just for class targets.
>
>     testsuite/
>
>      PR c++/87093
>     * g++.dg/ext/is_constructible2.C: New.
diff mbox series

Patch

diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 0b208a8..d75dacb 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1144,11 +1144,11 @@  static tree
 constructible_expr (tree to, tree from)
 {
   tree expr;
+  cp_unevaluated cp_uneval_guard;
   if (CLASS_TYPE_P (to))
     {
       tree ctype = to;
       vec<tree, va_gc> *args = NULL;
-      cp_unevaluated cp_uneval_guard;
       if (!TYPE_REF_P (to))
 	to = cp_build_reference_type (to, /*rval*/false);
       tree ob = build_stub_object (to);
diff --git a/gcc/testsuite/g++.dg/ext/is_constructible2.C b/gcc/testsuite/g++.dg/ext/is_constructible2.C
new file mode 100644
index 0000000..8f25e7e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/is_constructible2.C
@@ -0,0 +1,12 @@ 
+// { dg-do compile { target c++11 } }
+
+#include <type_traits>
+
+template <typename T> struct x {
+  operator bool() {
+    static_assert(!std::is_same<T, T>::value, "");
+    return false;
+  }
+};
+
+static constexpr auto a = __is_constructible(bool, x<int>);