[Bug c++/93905] [8 Regression] Cannot use Derived type of Base containing both enum and protected destructor

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Feb 25 12:11:00 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93905

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The reason this doesn't FAIL on 9 branch or trunk is
r9-3835-g5dab8b11c41fe72ea606c38884f7730bd2aeafdc , in particular the
@@ -5097,18 +5101,18 @@ cxx_eval_outermost_constant_expr (tree t, bool
allow_non_constant,

   if (TREE_CODE (r) == CONSTRUCTOR && CLASS_TYPE_P (TREE_TYPE (r)))
     {
+      r = adjust_temp_type (type, r);
       if (TREE_CODE (t) == TARGET_EXPR
          && TARGET_EXPR_INITIAL (t) == r)
        return t;
-      else
+      else if (TREE_CODE (t) != CONSTRUCTOR)
        {
          r = get_target_expr (r);
          TREE_CONSTANT (r) = true;
-         return r;
        }
     }
-  else
-    return r;
+
+  return r;
 }

 /* Returns true if T is a valid subexpression of a constant expression,
hunk from it (and for this testcase the adjust_temp_type isn't even needed, it
is purely about whether we call get_target_expr if t is a CONSTRUCTOR or not.
If I call it by hand on 9 branch, I get the same error.

Jason, I'm afraid I have no idea if e.g. just the else if (TREE_CODE (t) !=
CONSTRUCTOR) part could be safely cherry-picked alone, or if more changes are
needed, https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00197.html doesn't talk
about the particular reasons for not calling get_target_expr in that case. 
Reversion of the above commit is an option too, though it was a regression fix
too and we had it in 8.x for more than a year already, so some people might be
upset if NSDMIs with enums in it stop working again.


More information about the Gcc-bugs mailing list