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: [libiberty][PATCH] Avoid zero-length VLAs.


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


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