diff options
author | Jason Merrill <jason@redhat.com> | 2017-04-21 19:26:54 +0000 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2017-04-21 19:26:54 +0000 |
commit | f20530eb9bc186cba2b4c3a3405afeffd4da2bee (patch) | |
tree | 1b7f1130a6566026e8fc26a717b0af8ca08acc61 | |
parent | ca876f1149a5afe9ddbf795093a4be806e21b4da (diff) |
PR c++/80179 - ICE with initialized flexible array member.
* constexpr.c (verify_ctor_sanity): Handle flexible array members.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@247067 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/flexary24.C | 12 |
3 files changed, 27 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dad7a0a2520..6799e2edad9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +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> * cp-tree.h (copy_decl): Annotate with CXX_MEM_STAT_INFO. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 9dde4a4122a..366d562a8a6 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -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 the object is zero-initialized before calling the constructor. */ 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) || *(ctx->values->get (ctx->object)) == ctx->ctor); } diff --git a/gcc/testsuite/g++.dg/ext/flexary24.C b/gcc/testsuite/g++.dg/ext/flexary24.C new file mode 100644 index 00000000000..c25e540243a --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/flexary24.C @@ -0,0 +1,12 @@ +// PR c++/80179 +// { dg-options "" } + +struct S { + int n; + const char *a[]; +}; + +void bar (const char *a) +{ + static const S t = { 1, { a, "b" } }; +} |