re PR c++/68449 (ICE in cxx_eval_constant_expression on atomic_load in C++)
authorMarek Polacek <polacek@redhat.com>
Fri, 8 Jan 2016 19:08:37 +0000 (19:08 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 8 Jan 2016 19:08:37 +0000 (19:08 +0000)
PR c++/68449
* constexpr.c (cxx_eval_constant_expression): Handle NULL initializer.

* g++.dg/pr68449.C: New.

From-SVN: r232176

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr68449.C [new file with mode: 0644]

index 6b0eae6..49dc0cf 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-08  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/68449
+       * constexpr.c (cxx_eval_constant_expression): Handle NULL initializer.
+
 2016-01-08  Jason Merrill  <jason@redhat.com>
 
        * constexpr.c (cxx_eval_call_expression): Remove convert_to_void
index c6c3467..7b60271 100644 (file)
@@ -3184,7 +3184,8 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
        r = TARGET_EXPR_INITIAL (r);
       if (VAR_P (r))
        if (tree *p = ctx->values->get (r))
-         r = *p;
+         if (*p != NULL_TREE)
+           r = *p;
       if (DECL_P (r))
        {
          if (!ctx->quiet)
index 235eab7..c7162e2 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-08  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/68449
+       * g++.dg/pr68449.C: New.
+
 2016-01-08  Alan Lawrence  <alan.lawrence@arm.com>
 
        PR tree-optimization/68707
diff --git a/gcc/testsuite/g++.dg/pr68449.C b/gcc/testsuite/g++.dg/pr68449.C
new file mode 100644 (file)
index 0000000..7d86fe9
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/68449
+// { dg-do compile }
+// { dg-options "-Wsign-compare" }
+
+int
+foo (int a)
+{
+  return __extension__ ({ int b; b; }) < 0;
+}