bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: "Marc Nieper-Wißkirchen" <marc.nieper+gnu@gmail.com>, bug-gnulib@gnu.org
Subject: Re: 'const' function attribute
Date: Sun, 18 Oct 2020 16:27:35 +0200	[thread overview]
Message-ID: <1752685.sj3qNZAHk1@omega> (raw)
In-Reply-To: <e15b9d3d-bdc9-493b-1191-01a1b3b709fa@cs.ucla.edu>

Paul Eggert wrote:
> > To me, this is a pointless warning. Would you agree that a bug report to
> > the GCC people makes sense?
> 
> Yes and no. Theoretically, it makes sense that 'const' could apply to static 
> functions too. However the practical argument is weak. Programmers shouldn't be 
> bothering with 'const' on static functions, since the compiler should figure it 
> out. And with extern functions, 'const' would mean the API requires that the 
> function is a no-op, which is a pretty small niche case.

Indeed. Although GCC and clang don't have the same behaviour here (GCC gives
a warning, clang does not), it's pointless to declare that a public function
that returns 'void' has no side effects - because that is an implementation
detail that is subject to change.

So, not worth bothering the GCC people.


2020-10-18  Bruno Haible  <bruno@clisp.org>

	*-list, *-oset, *-omap: Avoid a GCC warning (regression 2020-10-10).
	* lib/gl_anylinked_list2.h (gl_linked_iterator_free): Remove
	'_GL_ATTRIBUTE_CONST'.
	* lib/gl_anytree_list2.h (gl_tree_iterator_free): Likewise.
	* lib/gl_anytree_omap.h (gl_tree_iterator_free): Likewise.
	* lib/gl_anytree_oset.h (gl_tree_iterator_free): Likewise.
	* lib/gl_array_list.c (gl_array_iterator_free): Likewise.
	* lib/gl_array_omap.c (gl_array_iterator_free): Likewise.
	* lib/gl_array_oset.c (gl_array_iterator_free): Likewise.
	* lib/gl_carray_list.c (gl_carray_iterator_free): Likewise.

diff --git a/lib/gl_anylinked_list2.h b/lib/gl_anylinked_list2.h
index bc9d5c7..24ef47e 100644
--- a/lib/gl_anylinked_list2.h
+++ b/lib/gl_anylinked_list2.h
@@ -1022,7 +1022,7 @@ gl_linked_iterator_next (gl_list_iterator_t *iterator,
     return false;
 }
 
-static void _GL_ATTRIBUTE_CONST
+static void
 gl_linked_iterator_free (gl_list_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }
diff --git a/lib/gl_anytree_list2.h b/lib/gl_anytree_list2.h
index 3cb3422..ae4d419 100644
--- a/lib/gl_anytree_list2.h
+++ b/lib/gl_anytree_list2.h
@@ -631,7 +631,7 @@ gl_tree_iterator_next (gl_list_iterator_t *iterator,
     return false;
 }
 
-static void _GL_ATTRIBUTE_CONST
+static void
 gl_tree_iterator_free (gl_list_iterator_t *iterator  _GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }
diff --git a/lib/gl_anytree_omap.h b/lib/gl_anytree_omap.h
index 016c83b..d8658c2 100644
--- a/lib/gl_anytree_omap.h
+++ b/lib/gl_anytree_omap.h
@@ -299,7 +299,7 @@ gl_tree_iterator_next (gl_omap_iterator_t *iterator,
     return false;
 }
 
-static void _GL_ATTRIBUTE_CONST
+static void
 gl_tree_iterator_free (gl_omap_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }
diff --git a/lib/gl_anytree_oset.h b/lib/gl_anytree_oset.h
index 46c47c2..5b3ab13 100644
--- a/lib/gl_anytree_oset.h
+++ b/lib/gl_anytree_oset.h
@@ -437,7 +437,7 @@ gl_tree_iterator_next (gl_oset_iterator_t *iterator, const void **eltp)
     return false;
 }
 
-static void _GL_ATTRIBUTE_CONST
+static void
 gl_tree_iterator_free (gl_oset_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }
diff --git a/lib/gl_array_list.c b/lib/gl_array_list.c
index 92bf463..3d9020e 100644
--- a/lib/gl_array_list.c
+++ b/lib/gl_array_list.c
@@ -508,7 +508,7 @@ gl_array_iterator_next (gl_list_iterator_t *iterator,
     return false;
 }
 
-static void _GL_ATTRIBUTE_CONST
+static void
 gl_array_iterator_free (gl_list_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }
diff --git a/lib/gl_array_omap.c b/lib/gl_array_omap.c
index c3117db..2bc5f5e 100644
--- a/lib/gl_array_omap.c
+++ b/lib/gl_array_omap.c
@@ -369,7 +369,7 @@ gl_array_iterator_next (gl_omap_iterator_t *iterator,
     return false;
 }
 
-static void _GL_ATTRIBUTE_CONST
+static void
 gl_array_iterator_free (gl_omap_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }
diff --git a/lib/gl_array_oset.c b/lib/gl_array_oset.c
index 5fb0da1..7832abc 100644
--- a/lib/gl_array_oset.c
+++ b/lib/gl_array_oset.c
@@ -487,7 +487,7 @@ gl_array_iterator_next (gl_oset_iterator_t *iterator, const void **eltp)
     return false;
 }
 
-static void _GL_ATTRIBUTE_CONST
+static void
 gl_array_iterator_free (gl_oset_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }
diff --git a/lib/gl_carray_list.c b/lib/gl_carray_list.c
index 8c2dc4e..e602516 100644
--- a/lib/gl_carray_list.c
+++ b/lib/gl_carray_list.c
@@ -680,7 +680,7 @@ gl_carray_iterator_next (gl_list_iterator_t *iterator,
     return false;
 }
 
-static void _GL_ATTRIBUTE_CONST
+static void
 gl_carray_iterator_free (gl_list_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }



  reply	other threads:[~2020-10-18 14:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-04 20:23 Unused parameter warnings Marc Nieper-Wißkirchen
2020-10-04 22:08 ` Bruno Haible
2020-10-06  5:58   ` Marc Nieper-Wißkirchen
2020-10-06 21:05     ` Bruno Haible
2020-10-07  6:07       ` Marc Nieper-Wißkirchen
2020-10-10 13:50         ` Bruno Haible
2020-10-10 14:31           ` Marc Nieper-Wißkirchen
2020-10-10 14:39             ` Bruno Haible
2020-10-10 15:00               ` Marc Nieper-Wißkirchen
2020-10-10 18:50                 ` Paul Eggert
2020-10-10 21:00                   ` Bruno Haible
2020-10-11 23:10                     ` Paul Eggert
2020-10-12  2:21                       ` Jeffrey Walton
2020-10-14  1:24                     ` 'const' function attribute Bruno Haible
2020-10-14 14:57                       ` Paul Eggert
2020-10-18 14:27                         ` Bruno Haible [this message]
2020-10-10 20:43             ` Unused parameter warnings Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1752685.sj3qNZAHk1@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=marc.nieper+gnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).