* Jakub Jelinek:

> On Wed, Jan 22, 2025 at 04:57:40PM -0700, Jerry James wrote:
>> On Wed, Jan 22, 2025 at 4:43 PM Chuck Anderson <c...@fea.st> wrote:
>> > It looks like most (all?) perl XS packages ('C' implementations of Perl 
>> > functions) are FTBFS with GCC 15.  I'm trying to fix 
>> > perl-Term-ReadLine-Gnu to be C23-compatible.  The workaround is to add 
>> > -std=gnu17 to the CFLAGS which can be done via OPTIMIZE for MakeMaker 
>> > builds like this:
>> >
>> > /usr/bin/perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS 
>> > -std=gnu17" NO_PACKLIST=1 NO_PERLLOCAL=1
>> >
>> > but I don't really know how to fix these the "right" way:
>> 
>> The issue is that "typedef int XFunction ();" used to say in C17 that
>> an XFunction returned an int and took an undeclared number and type of
>> parameters.  With C23, that says that an XFunction takes zero
>> parameters; i.e., it is equivalent to "typedef int XFunction (void);".
>> Try this patch:
>
> This is not correct.  Varargs functions like (...) are not compatible
> with non-varargs functions (so e.g. one which takes (FILE *), etc.).
> E.g. on x86-64 they have slightly different ABI (the varargs function
> need %rax to be number of floating point ... arguments) while non-vargs
> doesn't, but there could be other arches where it is completely ABI
> incompatible.

GCC used to pretend they were compatible in GCC 14:

void f(int, int);
void (*g) () = f;

I don't see a way to get a warning for this.  Perhaps it should have
been included in the -Wincompatible-pointer-types warning changes in GCC
14.  (Clang has -Wincompatible-function-pointer-types-strict for this.)

My point is that if GCC doesn't get this right, how do we expect
programmers to know this?  On POWER, the stack is corrupted in the
caller when certain variadic functions are called through a non-variadic
function pointer (or non-variadic prototype), and that can be really
hard to debug.

The other problem is that C does not have type like void * for function
pointers (perhaps even two—one for variadic functions, and one for
non-variadic functions).  Within Fedora, void * can serve this purpose,
but it is not portable.  Evidently, programmers and GCC though that
void (*) () was the function replacement for void *.

Thanks,
Florian

-- 
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to