Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFGcq_7Sg7quFrs1hzEGFAQLTdS77C66d5QvjVmU4R5Cy8WL_w@mail.gmail.com>
Date: Sat, 29 Nov 2025 14:53:15 +0100
From: Luca Kellermann <mailto.luca.kellermann@...il.com>
To: "From: Alejandro Colomar" <alx@...nel.org>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH v4 1/1] include/string.h: Implement QChar and QVoid
 wrappers standardized in C23

On Thu, 27 Nov 2025 17:27:27 +0100 Alejandro Colomar wrote:
> Co-authored-by: Markus Wichmann <nullplan@....net>
> Signed-off-by: Alejandro Colomar <alx@...nel.org>
> ---
>  include/string.h | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>
> diff --git a/include/string.h b/include/string.h
> index 83e2b946..454d93a7 100644
> --- a/include/string.h
> +++ b/include/string.h
> @@ -24,6 +24,15 @@ extern "C" {
>
>  #include <bits/alltypes.h>
>
> +#define __QVoidptrof(p)  typeof(1?(p):(void*)"")

Another expression to use instead of (void*)"" would be (void*){}. If
I'm not mistaken, this expression is not a null pointer constant, even
if its value is a null pointer. This would help avoid warnings with
-Wwrite-strings and -Wcast-qual.

> +#define __QCharptrof(s)  typeof                                       \
> +(                                                                     \
> +        _Generic(__QVoidptrof(s),                                     \
> +                const void *: (const char *) 0,                       \
> +                void *:       (char *) 0                              \
> +        )                                                             \
> +)

I think the controlling expression of a generic selection must be an
expression. __QVoidptrof(s) is a type. A compound literal could be
used instead:

_Generic((__QVoidptrof(s)){}, ...)

> [...]

Luca

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.