On Fri, Jan 08, 2016 at 12:56:15PM -0500, Jason Merrill wrote:
> On 01/08/2016 12:48 PM, Marek Polacek wrote:
> >     if (tree *p = ctx->values->get (r))
> >       r = *p;
> >-      if (DECL_P (r))
> >+      if (r == NULL_TREE || DECL_P (r))
> 
> I think it would be a bit better not to change r if *p is null.  OK with
> that change.

All right:

Bootstrapped/regtested on x86_64-linux, applying to trunk.

2016-01-08  Marek Polacek  <pola...@redhat.com>

        PR c++/68449
        * constexpr.c (cxx_eval_constant_expression): Handle NULL initializer.

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

diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index c6c3467..7b60271 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -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)
diff --git gcc/testsuite/g++.dg/pr68449.C gcc/testsuite/g++.dg/pr68449.C
index e69de29..7d86fe9 100644
--- gcc/testsuite/g++.dg/pr68449.C
+++ gcc/testsuite/g++.dg/pr68449.C
@@ -0,0 +1,9 @@
+// PR c++/68449
+// { dg-do compile }
+// { dg-options "-Wsign-compare" }
+
+int
+foo (int a)
+{
+  return __extension__ ({ int b; b; }) < 0;
+}

        Marek

Reply via email to