Hi, Jeffrey Cliff <[email protected]> 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ć
signature.asc
Description: PGP signature
