From: Jason Merrill Date: Sun, 31 May 2015 20:36:18 +0000 (-0400) Subject: re PR c++/66320 (ICE: in cxx_eval_constant_expression, at cp/constexpr.c:3524) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6ad6af49da1d0e069cb828fa2a8b846b326caada;p=gcc.git re PR c++/66320 (ICE: in cxx_eval_constant_expression, at cp/constexpr.c:3524) PR c++/66320 * constexpr.c (cxx_eval_constant_expression): Treat a placeholder with the wrong type as non-constant. From-SVN: r223901 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 774c36e5379..5029f8320b9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-05-31 Jason Merrill + + PR c++/66320 + * constexpr.c (cxx_eval_constant_expression): Treat a placeholder + with the wrong type as non-constant. + 2015-05-27 Jason Merrill * decl.c (check_redeclaration_exception_specification): Depend on diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f35ec1e013f..f343ea7eae0 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -3458,7 +3458,9 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, break; case PLACEHOLDER_EXPR: - if (!ctx || !ctx->ctor || (lval && !ctx->object)) + if (!ctx || !ctx->ctor || (lval && !ctx->object) + || !(same_type_ignoring_top_level_qualifiers_p + (TREE_TYPE (t), TREE_TYPE (ctx->ctor)))) { /* A placeholder without a referent. We can get here when checking whether NSDMIs are noexcept, or in massage_init_elt; @@ -3473,8 +3475,6 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, use ctx->object unconditionally, but using ctx->ctor when we can is a minor optimization. */ tree ctor = lval ? ctx->object : ctx->ctor; - gcc_assert (same_type_ignoring_top_level_qualifiers_p - (TREE_TYPE (t), TREE_TYPE (ctor))); return cxx_eval_constant_expression (ctx, ctor, lval, non_constant_p, overflow_p); diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi11.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi11.C new file mode 100644 index 00000000000..29942b07b8a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi11.C @@ -0,0 +1,23 @@ +// PR c++/66320 +// { dg-do compile { target c++11 } } + +class A +{ + virtual int m_fn1 (); +}; +class B +{ +public: + B (int); +}; +class D : B +{ + struct C + { + A a; + A b = a; + }; + D (int *); + C _channels; +}; +D::D (int *) : B (0) {}