bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fun with c23


From: Jeffrey Cliff
Subject: Re: fun with c23
Date: Fri, 9 Aug 2024 08:27:09 -0600

looks like the above thread covers pretty much everything (I'm OK with
it just being fixed in main myself, no need for bug release on my
account anyway)

> AFAICT it isn't, I don't see it anywhere in the build system.  So that
probably needs fixing.

If I've done it correctly this seems to to be what would look like

# diff -Naur texinfo-7.1/configure.ac texinfo-7.1-configures/configure.ac
--- texinfo-7.1/configure.ac 2023-10-18 07:06:07.000000000 -0600
+++ texinfo-7.1-configures/configure.ac 2024-08-09 07:42:38.760352465 -0600
@@ -623,3 +623,7 @@
   AC_MSG_WARN([Perl module Unicode::Collate was not found.])
   AC_MSG_WARN([texi2any may sort document indices incorrectly.])
 fi
+
+
+
+AC_CHECK_FUNC(strerror,[[ #define HAVE_DECL_STRERROR 1 ]])

but it doesn't seem to be necessary:  ie if main already removed the
strerrr definition (ie by
https://gnu.googlesource.com/texinfo/+/3d202924c8ddd96029129bb745772cb2918a5f10
)

Jeff Cliff

On Fri, Aug 9, 2024 at 2:06 AM Arsen Arsenović <arsen@aarsen.me> wrote:
>
> Hi,
>
> Jeffrey Cliff <jeffrey.cliff@gmail.com> writes:
>
> > tl;dr c23 changes break compilation. 2 small patches
> >
> > [Firstly: apologize if this went to the wrong list - according to my
> > (terrible) email provider it didn't go out.  Hopefully this is the
> > correct list]
>
> I don't see a different email, and this is the right list for bug
> reports, so I think you're OK :-)
>
> > Looks like at least two kinds of changes to C coming with C23 (ie
> > compiling with -std=gnu2x / gnu23), both involving changes to the
> > arguments of functions and how explicit you have to be about them.
> > And when I compile with -std=gnu23 (ie compile to the C23 standard) it
> > means 2 compilation problems result:
> >
> > 1)
> > * whereas before it was OK to define strerror without being explicit
> > about its argument,
> > it seems to depend on an int being provided as an argument
>
> Not really - it hasn't been okay for decades and has been causing subtle
> bugs.  We've changed GCC 14 to diagnose this error, though, to subtle
> fallout all over the place.
>
> > /usr/include/string.h
> >   419 | extern char *strerror (int __errnum) __THROW;
> >       |              ^~~~~~~~
> >
> > (man 3 strerror seems to agree: it should have an argument
> >
> > char *strerror(int errnum);
> >
> > so when ./system.h attempts to define it
> >
> > #ifndef HAVE_DECL_STRERROR
> > extern char *strerror ();
> > #endif
> >
> > for some reason two things go wrong
> > i) gcc doesn't seem to define HAVE_DECL_STRERROR leading to ( ???
> > google is telling me nothing about how this is supposed to be defined
> > )
>
> AFAICT it isn't, I don't see it anywhere in the build system.  So that
> probably needs fixing.
>
> > ii) an attempt made to define it externally with the wrong definition
> >
> > changing it to
> > extern char *strerror (int);
> > or better yet
> >
> > extern char *strerror (int) __THROW;
> >
> > makes it at least compile past that point.
> >
> > then the real fun starts
> >
> > 2) because there's a *whole bunch* of functions declared as VFunctions
> > with various kinds of arguments (for example cmd in echo-area.c and
> > m-x.c 's command-func)
> >
> > Now the good news is: c23 provides a way to change the VFunction
> > definition to not care about the argument abuse so frequently employed
> > : the '...' type.  (Which is also fun to search for information on -
> > https://thephd.dev/c23-is-coming-here-is-what-is-on-the-menu guess the
> > technical term is "variadic parameter lists" ).
>
> But that fix is incorrect unless the actual functions are variadic also.
> It's better not to use these typedefs.  Also ... is not a type, and
> unprototyped functions aren't the same as variadic ones.  The solution
> suggested in the blogpost, as noted, requires non-standard support from
> the compiler vendor.
>
> > OK now for the changes to fix it.
> >
> > one thing is to just #ifdef guard the change needed to get it to
> > compile with c23 on both info/info.h and ./system.h
> >
> > # diff -Naur texinfo-7.1/system.h texinfo-7.1-compiles/system.h
> > --- texinfo-7.1/system.h 2023-08-15 06:00:01.000000000 -0600
> > +++ texinfo-7.1-compiles/system.h 2024-08-08 23:20:03.613636469 -0600
> > @@ -66,7 +66,12 @@
> >  #endif
> >
> >  #ifndef HAVE_DECL_STRERROR
> > -extern char *strerror ();
> > +#if __STDC_VERSION__ < 202311L
> > +extern char *strerror () ;
> > +#endif
> > +#if __STDC_VERSION__ >= 202311L
> > +extern char *strerror (int) __THROW;
> > +#endif
> >  #endif
> >
> >  #include <limits.h>
>
> Better fix this to actually use the system definition.  Plus __THROW is
> a glibc implementation detail.
>
> > # diff -Naur texinfo-7.1/info/info.h texinfo-7.1-compiles/info/info.h
> > --- texinfo-7.1/info/info.h 2023-08-14 12:53:20.000000000 -0600
> > +++ texinfo-7.1-compiles/info/info.h 2024-08-08 23:22:44.454624287 -0600
> > @@ -25,7 +25,13 @@
> >
> >  /* Some of our other include files use these.  */
> >  typedef int Function ();
> > +#if __STDC_VERSION__ < 202311L
> >  typedef void VFunction ();
> > +#endif
> > +#if __STDC_VERSION__ >= 202311L
> > +typedef void VFunction (...);
> > +#endif
> > +
> >  typedef char *CFunction ();
> >
> >  #include "string.h"
> >
> > or do so just with the info.h one and just make the changes to the
> > extern definition in system.h (that works for me (TM))
> >
> > Either way that gets it compiling on my end (with CFLAGS+="
> > -std=gnu2x" and gnu23).
> >
> > Jeff Cliff
>
> Thanks for the report.
> --
> Arsen Arsenović



-- 
------------------------------------------------------------------------------------------------
End the campaign to Cancel Richard Stallman - go to stallmansupport.org !
------------------------------------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]