Re: incorrect use of 'pure' attribute

Bruno Haible via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <2602973.oqx4rD5t72@cagnes>
Hi Sam,

Sam James wrote:
> A function being idempotent / having 'call_once'
> semantics unfortunately doesn't make it suitable for the const
> attribute. This recently came up in both Mesa [0] and glib [1]
> and was confirmed by the GCC developers [2].
> 
> [0] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42361
> [1] https://gitlab.gnome.org/GNOME/glib/-/work_items/3984
> [2] https://gcc.gnu.org/PR125916

Rather than have to manually review whole packages for this kind of
mistake, I think it would be good to have compiler warnings about these
incorrect uses of the 'const' and 'pure' attributes. Therefore I've
registered two issues for gcc and clang, respectively:

const:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126757
  https://github.com/llvm/llvm-project/issues/215105

pure:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126758
  https://github.com/llvm/llvm-project/issues/215106

Bruno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.