Commit 176e79b5 by Jason Merrill Committed by Jason Merrill

PR c++/80179 - ICE with initialized flexible array member.

	* constexpr.c (verify_ctor_sanity): Handle flexible array members.

From-SVN: r247067
parent f2f3e54d
2017-04-21 Jason Merrill <jason@redhat.com>
PR c++/80179 - ICE with initialized flexible array member.
* constexpr.c (verify_ctor_sanity): Handle flexible array members.
2017-04-21 Richard Biener <rguenther@suse.de> 2017-04-21 Richard Biener <rguenther@suse.de>
* cp-tree.h (copy_decl): Annotate with CXX_MEM_STAT_INFO. * cp-tree.h (copy_decl): Annotate with CXX_MEM_STAT_INFO.
......
...@@ -2643,8 +2643,16 @@ verify_ctor_sanity (const constexpr_ctx *ctx, tree type) ...@@ -2643,8 +2643,16 @@ verify_ctor_sanity (const constexpr_ctx *ctx, tree type)
/* We used to check that ctx->ctor was empty, but that isn't the case when /* We used to check that ctx->ctor was empty, but that isn't the case when
the object is zero-initialized before calling the constructor. */ the object is zero-initialized before calling the constructor. */
if (ctx->object) if (ctx->object)
gcc_assert (same_type_ignoring_top_level_qualifiers_p {
(type, TREE_TYPE (ctx->object))); tree otype = TREE_TYPE (ctx->object);
gcc_assert (same_type_ignoring_top_level_qualifiers_p (type, otype)
/* Handle flexible array members. */
|| (TREE_CODE (otype) == ARRAY_TYPE
&& TYPE_DOMAIN (otype) == NULL_TREE
&& TREE_CODE (type) == ARRAY_TYPE
&& (same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (type), TREE_TYPE (otype)))));
}
gcc_assert (!ctx->object || !DECL_P (ctx->object) gcc_assert (!ctx->object || !DECL_P (ctx->object)
|| *(ctx->values->get (ctx->object)) == ctx->ctor); || *(ctx->values->get (ctx->object)) == ctx->ctor);
} }
......
// PR c++/80179
// { dg-options "" }
struct S {
int n;
const char *a[];
};
void bar (const char *a)
{
static const S t = { 1, { a, "b" } };
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment