This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] handle multiple flexible array members (PR 83588)


On 01/15/2018 07:10 PM, Jason Merrill wrote:
OK.

Thanks.  I keep forgetting to get approval to backport these
simple bug fixes.  Is this one okay for the 7 and 6 branches?

Martin


On Sun, Jan 14, 2018 at 6:47 PM, Martin Sebor <msebor@gmail.com> wrote:
The attached patch fixes PR c++/83588 - struct with two flexible
arrays causes an internal compiler error.  The ICE is caused by
the same assertion in varasm.c that has led to other similar
reports in the past:

  /* Given a non-empty initialization, this field had better
     be last.  Given a flexible array member, the next field
     on the chain is a TYPE_DECL of the enclosing struct.  */
  const_tree next = DECL_CHAIN (local->field);
  gcc_assert (!fieldsize || !next || TREE_CODE (next) != FIELD_DECL);

The fix is simply to also detect when a class defines more than
one flexible array member and treat the subsequent array as any
other member, and reject such class definitions to make sure they
never reach the assertion above.

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]