This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [libiberty][PATCH] Avoid zero-length VLAs.
- From: Brooks Moses <bmoses at google dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 11 Jul 2016 16:49:14 -0700
- Subject: Re: [libiberty][PATCH] Avoid zero-length VLAs.
- Authentication-results: sourceware.org; auth=none
- References: <CAOxa4KrBsAQ7JuY=f2ZPf0SWboxa0p7wvrefxFGvqwmzUL_Mzw@mail.gmail.com> <CAOxa4Koa5zc0UFJo2pJ6nXw5j3Hvbq63C767ALCHXNYJ_PR3Mw@mail.gmail.com> <CAKOQZ8ytEq0-+r=hb+p7DUM6RjSQ4km49uvH2yruP89s3uNe5g@mail.gmail.com>
On Mon, Jul 11, 2016 at 4:27 PM, Ian Lance Taylor <iant@google.com> wrote:
> On Mon, Jul 11, 2016 at 1:05 PM, Brooks Moses <bmoses@google.com> wrote:
>> Ping?
>
> This is fine, but please add a comment explaining why the code avoids
> 0-length VLAs. Thanks.
Thanks!
Committed as r238233. This is the comment I added:
+ /* Avoid zero-length VLAs, which are prohibited by the C99 standard
+ and flagged as errors by Address Sanitizer. */
+ __extension__ struct d_saved_scope scopes[(dpi.num_saved_scopes > 0)
+ ? dpi.num_saved_scopes : 1];
+ __extension__ struct d_print_template temps[(dpi.num_copy_templates > 0)
+ ? dpi.num_copy_templates : 1];
- Brooks