Pádraig Brady <[email protected]> writes:

> On 14/10/2026 07:59, Collin Funk wrote:
>> One mildly interesting thing I noticed while writing this patch is
>> that gcc will give the following warning, but clang will not:
>>      table.rows[table.nrows++] = xinmalloc (table.ncolumns,
>>                                             sizeof *table.rows[0]);
>>      src/df.c: In function 'alloc_table_row':
>>      src/df.c:381:25: warning: operation on 'table.nrows' may be undefined 
>> [-Wsequence-point]
>>        381 |   table.rows[table.nrows++] = xinmalloc (table.ncolumns,
>>            |              ~~~~~~~~~~~^~
>> It only shows up when COUNTED_BY is in use. Whether it is correct to
>> warn is unclear to me. My memory of that area of the standard is poor.
>
>
> GCC might implicitly read table.nrows when accessing the annotated table.rows.
> It is a bit annoying to have the extra temp var to enforce the sequence.
>
> Anyway LGTM.

I agree. I suspect the divergence here will make it harder for people to
adopt these new attributes, so I will try to come up with a standalone
reproducer to report to the GCC people and see what they think.

Collin

Reply via email to