[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: |
arnold |
Subject: |
Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23 |
Date: |
Sun, 11 Aug 2024 21:31:55 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
I am pushing my changes. Thanks for the report.
Jeffrey Cliff <jeffrey.cliff@gmail.com> wrote:
> Of course.
>
> * this also occurs on main / c190576f
>
> * read in this question is just read(2)
> ssize_t read(int fd, void buf[.count], size_t count);
>
> * interestingly, it seems like gcc is smart enough to figure out what
> the type read_func needs without explicit casting(?) -- ie just
> getting rid of explicit cast allows not only compile, but all tests to
> work(?) and gawk seems to run fine
>
> so one possible fix is just something like
>
> # git diff c190576fd345d9c098901061f0fd4164a7bfc87f io.c
> diff --git a/io.c b/io.c
> index 3943c5a9..54abf110 100644
> --- a/io.c
> +++ b/io.c
> @@ -3388,7 +3388,12 @@ iop_alloc(int fd, const char *name, int errno_val)
>
> iop->public.fd = fd;
> iop->public.name = name;
> - iop->public.read_func = ( ssize_t(*)() ) read;
> + #if __STDC_VERSION__ >= 202311L
> + iop->public.read_func = read;
> + #else
> + iop->public.read_func = ( (ssize_t(*)() ) read;
> + #endif
> +
> iop->valid = false;
> iop->errcode = errno_val;
>
>
> On Sat, Aug 10, 2024 at 12:07 PM <arnold@skeeve.com> wrote:
> >
> > Hi.
> >
> > Thanks for the report. I recommend not using -std=gnu23. I have to
> > support many older compilers, so gawk purposely is not expected
> > to follow the latest standards.
> >
> > Thanks,
> >
> > Arnold
> >
> > Jeffrey Cliff <jeffrey.cliff@gmail.com> wrote:
> >
> > > Configuration Information [Automatically generated, do not change]:
> > > Machine: x86_64
> > > OS: linux-gnm
> > > Compiler: gcc (GCC) 15.0.0 20240509 (experimental)
> > > Compilation CFLAGS: -std=gnu23 -DNDEBUG
> > > uname output: Linux fatima 6.10.3-gnu-c23-qxfixgnm #2 SMP
> > > PREEMPT_DYNAMIC Wed Aug 7 20:46:44 CST 2024 x86_64 GNU/Linux
> > > Machine Type: x86_64-pc-linux-gnu
> > >
> > > Gawk Version: 5.3.0*
> > >
> > > Attestation 1:
> > > I have read
> > > https://www.gnu.org/software/gawk/manual/html_node/Bugs.html.
> > > Yes
> > >
> > > Attestation 2:
> > > I have not modified the sources before building gawk.
> > > True
> > >
> > > Description:
> > >
> > > compilation fails at io.c:
> > >
> > > # gcc -DDEFPATH='".:/usr/local/share/awk"'
> > > -DDEFLIBPATH="\"/usr/local/lib/gawk\"" -DSHLIBEXT="\"so"\"
> > > -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/usr/local/share/locale"'
> > > -I"./support" -I. -std=gnu23 -DND\
> > > EBUG -std=gnu23 -DNDEBUG -MT io.o -MD -MP -MF $depbase.Tpo -c -o io.o
> > > io.c &&\
> > > mv -f $depbase.Tpo $depbase.Po
> > > io.c: In function 'iop_alloc':
> > > io.c:3389:31: error: assignment to 'ssize_t (*)(int, void *,
> > > size_t)' {aka 'long int (*)(int, void *, long unsigned int)'} from
> > > incompatible pointer type 'ssize_t (*)(void)' {aka 'long int
> > > (*)(void)'}\
> > > [-Wincompatible-pointer-types]
> > > 3389 | iop->public.read_func = ( ssize_t(*)() ) read;
> > > | ^
> > > io.c: In function 'get_read_timeout':
> > > io.c:4449:36: warning: comparison of distinct pointer
> > > types lacks a cast [-Wcompare-distinct-pointer-types]
> > > 4449 | if ((iop->public.read_func == (
> > > ssize_t(*)() ) read) && tmout > 0)
> > > | ^~
> > >
> > > Repeat-By:
> > > setting CFLAGS to -std=gnu23 on gcc new enough to support it
> > >
> > > ( installed gawk is 5.2.2 trying to upgrade to 5.3.0 )
>
>
>
> --
> ------------------------------------------------------------------------------------------------
> End the campaign to Cancel Richard Stallman - go to stallmansupport.org !
> ------------------------------------------------------------------------------------------------
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, (continued)
- 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, 2024/08/11
- 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 <=