Evaluation of constant expressions, such as those passed to
static_assert, ICEd when encountering IMPLICIT_CONV_EXPRs.

Handle them like CONVERT_EXPR and NOP_EXPR.

Regstrapped on x86_64- and i686-linux-gnu.  Ok to install?

for  gcc/cp/ChangeLog

        PR c++/84596
        * constexpr.c (cxx_eval_constant_expression): Handle
        IMPLICIT_CONV_EXPR.

for  gcc/testsuite/ChangeLog

        PR c++/84596
        * g++.dg/cpp0x/pr84596.C: New.
---
 gcc/cp/constexpr.c                   |    1 +
 gcc/testsuite/g++.dg/cpp0x/pr84596.C |    7 +++++++
 2 files changed, 8 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr84596.C

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 4bbdbf434877..d38e2d83ae8c 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4549,6 +4549,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, 
tree t,
                                       non_constant_p, overflow_p);
       break;
 
+    case IMPLICIT_CONV_EXPR:
     case CONVERT_EXPR:
     case VIEW_CONVERT_EXPR:
     case NOP_EXPR:
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr84596.C 
b/gcc/testsuite/g++.dg/cpp0x/pr84596.C
new file mode 100644
index 000000000000..ee709f4200fe
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr84596.C
@@ -0,0 +1,7 @@
+// PR c++/84596
+// { dg-do compile { target c++11 } }
+
+template<int x>
+void b(int c) {
+  static_assert (c, "c"); // { dg-error "non-constant|not a constant" }
+}

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer

Reply via email to