coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] maint: df: refactor rows and columns to use COUNTED_BY


From: Pádraig Brady
Subject: Re: [PATCH] maint: df: refactor rows and columns to use COUNTED_BY
Date: Wed, 14 Oct 2026 13:32:27 +0100
User-agent: Mozilla Thunderbird Beta

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.

thanks,
Padraig.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]