[Bug c++/69487] Unexpected VLA initialization of char[] from ""

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 26 13:54:00 GMT 2016


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-01-26
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The dumped trees show a memcpy from "" with the length as the length of the
array:

  __builtin_memcpy (buffer.1_23, "", _15);

That should presumably use strnlen("", _15 - 1) or just be consistent with the
C front-end and reject it:

vla.c:20:5: error: variable-sized object may not be initialized


More information about the Gcc-bugs mailing list