Re: incorrect use of 'pure' attribute
Sam James <[email protected]>
| Newsgroups | gmane.comp.lib.gnulib.bugs |
|---|---|
| Organization | Gentoo |
| Message-ID | <[email protected]> |
Bruno Haible via Gnulib discussion list <[email protected]> writes: > Hi Arsen, > > In <https://lists.gnu.org/archive/html/bug-gettext/2026-08/msg00000.html> you > write: >> Pure functions cannot have any observable effects other than their >> return value. Thus, it is not valid for a pure function to have an >> out-parameter. >> ... >> Please, when you get the chance, audit the usages of _GL_ATTRIBUTE_PURE >> to check whether marked-pure functions have out-params. > > Thank you for the suggestion. Just did an audit of Gnulib: > - There are indeed 6 functions marked 'pure' but which have out parameters. > They need to be marked 'reproducible', not 'pure'. > - There are also a couple of functions marked 'pure' where it is not > immediately clear from the prototype whether these have out parameters. I did a quick audit as well after your changes. They look good, thank you! I found one issue left: __eloop_threshold isn't const and a comment acknowledges this. 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 thanks, sam > [...]
signature.asc
(application/pgp-signature, 418 B)
-----BEGIN PGP SIGNATURE----- iQEBBAEWCgCpFiEEJaa7iN2bdkxrVUHCc4QJ9SDfkZAFAmp2efIbFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25z Lm9wZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQyNUE2QkI4OEREOUI3NjRDNkI1NTQx QzI3Mzg0MDlGNTIwREY5MTkwDxxzYW1AZ2VudG9vLm9yZwAKCRBzhAn1IN+RkJB8 AQCDbJkbfOUWkm9xKIxMYTjnyuN+YVYZKljPFUM2hT308QEA1nGxmp49EiCDq9kT mWzwq5Lu6dJ+hzs+8S8ifWfz9gU= =uXEp -----END PGP SIGNATURE-----