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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 41072
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41072&action=edit
gcc7-pr79993.patch

So, one option is to revert to the 4.8 and earlier behavior, disallow any VLA
initialization (like C does).  This patch should do it.

Otherwise, the behavior the C++ FE has when not using string literals as
initializers is that it is UB if the VLA is smaller than the size of the
initializer, and if it is larger or equal than that, it is initialized from the
initializer and excess elements if any are zero initialized (value
initialization or whatever it is).  Even when ignoring the bogus type on the
STRING_CST, we don't implement that right now for STRING_CST - we probably want
memcpy from the STRING_CST followed by whatever we do for other initializers.

Reply via email to