emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#68267: closed ([PATCH] maint: add attributes to two functions withou


From: GNU bug Tracking System
Subject: bug#68267: closed ([PATCH] maint: add attributes to two functions without side effects)
Date: Sat, 06 Jan 2024 15:35:01 +0000

Your message dated Sat, 6 Jan 2024 15:34:07 +0000
with message-id <8f5a4d0c-4cd7-02ae-e48a-e2a8fa71e3e6@draigBrady.com>
and subject line Re: bug#68267: [PATCH] maint: add attributes to two functions 
without side effects
has caused the debbugs.gnu.org bug report #68267,
regarding [PATCH] maint: add attributes to two functions without side effects
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
68267: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68267
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] maint: add attributes to two functions without side effects Date: Fri, 5 Jan 2024 17:44:06 +0100
* 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.
---
Resent here, I sent it to the coreutils@ mailing-list while the hacking
doc says to send it here.

 src/date.c | 1 +
 src/tee.c  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/date.c b/src/date.c
index 39fc0715d..03bf012e2 100644
--- a/src/date.c
+++ b/src/date.c
@@ -294,6 +294,7 @@ Show the local time for 9AM next Friday on the west coast 
of the US\n\
 /* Yield the number of decimal digits needed to output a time with the
    nanosecond resolution RES, without losing information.  */
 
+ATTRIBUTE_CONST
 static int
 res_width (long int res)
 {
diff --git a/src/tee.c b/src/tee.c
index 07d525c95..eb074427c 100644
--- a/src/tee.c
+++ b/src/tee.c
@@ -185,6 +185,7 @@ main (int argc, char **argv)
 /* Return the index of the first non-null descriptor after idx,
    or -1 if all are null.  */
 
+ATTRIBUTE_PURE
 static int
 get_next_out (FILE **descriptors, int nfiles, int idx)
 {
-- 
2.42.0




--- End Message ---
--- Begin Message --- Subject: Re: bug#68267: [PATCH] maint: add attributes to two functions without side effects Date: Sat, 6 Jan 2024 15:34:07 +0000 User-agent: Mozilla Thunderbird
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


--- End Message ---

reply via email to

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