Subject: Re: bug#68267: [PATCH] maint: add attributes to two functions without side effects
From: Pádraig Brady <[email-masked]>
To: Samuel Tardieu <[email-masked]>, [email-masked]
Date: Sat, 6 Jan 2024 15:34:07 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

On 05/01/2024 16:44, Samuel Tardieu wrote:
> * src/date.c (res_width): This function computes its result solely
> from the value of its parameter and qualifies for the const attribute.
> * src/tee.c (get_next_out): This function has no side effect and
> qualifies for the pure attribute.
> 
> Those two functions were flagged by GCC 12.3.0.

I'm guessing GCC 12 needs help here as it can't determine the loops are finite.
(as per: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109914 )

Though I'm not seeing this suggestion with GCC 13.2.1,
so perhaps GCC 12 can determine the loops are finite?

I'll apply this since GCC 13 is less that a year old,
but in general we try to avoid littering code like this.

thanks,
Pádraig