[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: io.c incompatible pointer between public.read_func and ssize_t(*)()
From: |
Collin Funk |
Subject: |
Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23 |
Date: |
Sat, 10 Aug 2024 21:57:15 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Eli Zaretskii <eliz@gnu.org> writes:
> The comment you are removing clearly says that the issue the cast is
> trying to solve is with ancient systems whose prototype of 'read'
> either doesn't exist or is not identical/compatible with 'readfunc'.
> If this is the issue, then a trivial wrapper around 'read' is IMO
> cleaner:
[...]
> Casts are less clean, and can even be dangerous if the actual
> signature is really different.
+1, the casts are undefined behavior in that case. In C23 Annex J,
listing some common undefined behavior [1]:
(23) A pointer is used to call a function whose type is not
compatible with the referenced type (6.3.3.3).
Using 'void *' to store function pointers is also undefined behavior,
but is allowed on POSIX systems, per dlsym [2].
Collin
[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3301.pdf
[2] https://pubs.opengroup.org/onlinepubs/9799919799/functions/dlsym.html
- io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Jeffrey Cliff, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, arnold, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Jeffrey Cliff, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Eli Zaretskii, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, arnold, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Jeffrey Cliff, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, arnold, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Eli Zaretskii, 2024/08/11
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23,
Collin Funk <=
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, arnold, 2024/08/11
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Eli Zaretskii, 2024/08/11
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, arnold, 2024/08/11