Re: [PATCH GnuPG 1/7] common: fix -Wdiscarded-qualifiers

Werner Koch via Gnupg-devel <[email protected]> Tue, 17 Feb 2026 09:16:03 +0100
Newsgroups gmane.comp.encryption.gpg.devel
Message-ID <[email protected]>
Hi!

> glibc-2.43 with -std=gnu23/-std=c23 (default in >= GCC 15) implements
> C23's const-preserving macros for stdlib functions (i.e. you pass in
> a const pointer, you get one back). Fix some resulting warnings.

That is actually a cool idea but it breaks current coding practise.

For example

> -  passwd_nonce = option_value (line, "--passwd-nonce");
> +  passwd_nonce = (char *) option_value (line, "--passwd-nonce");

That casting is worse than the original code.  The idea of those macros
seems to be to avoid just the need for casts.  Now we have them back.

To make real use of these macros I considere it better to write code
with C23 in mind.  However, this breaks portability on many platforms.
There are actually other compilers than gcc and llvm.  And older
platforms do not update their compilers at all.

Thanks for the patch, but I won't apply it.


Salam-Shalom,

   Werner

-- 
The pioneers of a warless world are the youth that
refuse military service.             - A. Einstein

_______________________________________________
Gnupg-devel mailing list
[email protected]
https://lists.gnupg.org/mailman/listinfo/gnupg-devel
openpgp-digital-signature.asc (application/pgp-signature, 284 B)
-----BEGIN PGP SIGNATURE-----

iJ8EARYKAEcWIQSHd0YfKgdOvEgNNZQZzByeCFsQegUCaZQjwxsUgAAAAAAEAA5t
YW51MiwyLjUrMS4xMSwyLDINHHdrQGdudXBnLm9yZwAKCRAZzByeCFsQejPPAQDA
M4RgIdBSvyPUP1UJbalarxRt0cNOoZ4vJ3dLZNjnJQD/UM51ezPVWYde7qmb9mor
1qOQM63t3AB5zQ7cMWwESQM=
=kkTc
-----END PGP SIGNATURE-----