PR# 19927 GCC 14 -Wincompatible-pointer-types

Problem Report Summary
Submitter: imustafin
Category: C Compilation
Priority: Low
Date: 2024/06/14
Class: Bug
Severity: Critical
Number: 19927
Release: 24.05.10.7822
Confidential: No
Status: Analyzed
Responsible:
Environment: linux
Synopsis: GCC 14 -Wincompatible-pointer-types

Description
In GCC 14 warning incompatible-pointer-types was promoted from a warning to an error. This makes it impossible to compile the attached code.

Note that the attached project has <void_safety support="none"/>. Removing this line makes the code compile.

I think I saw this warning in several previous versions of EiffelStudio. I can confirm that the same error occurs in 23.09.

Possible workaround for users:
Add -Wno-error=incompatible-pointer-types to C Flags of your project.

Possible workaround for the Eiffel compiler:
Check https://gcc.gnu.org/gcc-14/porting_to.html ,
specifically the sections "Type checking on pointer types (-Werror=incompatible-pointer-types)"
and "Accommodating C code generators".


I'm not sure what is the purpose of TYPE.adapt but it is used by the code I don't control, so I must compile it.

My gcc is:
$ gcc --version
gcc (GCC) 14.1.1 20240522
To Reproduce
Have gcc 14. Unpack the code and do a clean compile with C code compilation. Observer the errors:
In file included from /home/ilgiz/uni/Eiffel_24.05/studio/spec/linux-x86-64/include/eif_globals.h:47,
                 from /home/ilgiz/uni/Eiffel_24.05/studio/spec/linux-x86-64/include/eif_eiffel.h:49,
                 from ac684.c:5,
                 from big_file_C21_c.c:1:
ty660.c: In function ‘F660_3018’:
/home/ilgiz/uni/Eiffel_24.05/studio/spec/linux-x86-64/include/eif_macros.h:1267:44: error: passing argument 1 of ‘eif_xequal’ from incompatible pointer type [-Wincompatible-pointer-types]
 1267 | #define RTEQ(x,y)               eif_xequal((x),(y))
      |                                            ^~~
      |                                            |
      |                                            EIF_NATURAL_16 * {aka short unsigned int *}
ty660.c:870:21: note: in expansion of macro ‘RTEQ’
  870 |                 if (RTEQ(Result, arg1)) {
      |                     ^~~~
In file included from /home/ilgiz/uni/Eiffel_24.05/studio/spec/linux-x86-64/include/eif_macros.h:44:
/home/ilgiz/uni/Eiffel_24.05/studio/spec/linux-x86-64/include/eif_equal.h:53:45: note: expected ‘EIF_REFERENCE’ {aka ‘char *’} but argument is of type ‘EIF_NATURAL_16 *’ {aka ‘short unsigned int *’}
   53 | RT_LNK EIF_BOOLEAN eif_xequal(EIF_REFERENCE ref1, EIF_REFERENCE ref2);                          /* Equality with no conformance constraint */
      |                               ~~~~~~~~~~~~~~^~~~
ty665.c: In function ‘F665_3018’:
/home/ilgiz/uni/Eiffel_24.05/studio/spec/linux-x86-64/include/eif_macros.h:1267:44: error: passing argument 1 of ‘eif_xequal’ from incompatible pointer type [-Wincompatible-pointer-types]
 1267 | #define RTEQ(x,y)               eif_xequal((x),(y))
      |                                            ^~~
      |                                            |
      |                                            EIF_REAL_32 * {aka float *}
ty665.c:870:21: note: in expansion of macro ‘RTEQ’
  870 |                 if (RTEQ(Result, arg1)) {
      |                     ^~~~
Problem Report Interactions
From:jfiat_es    Date:2024/06/17    Status: Analyzed    Download   
Thank you for your report, we are looking at the issue.

From:imustafin    Date:2024/06/14    Download   
Attachments for problem report #19927

Attachment: application.e     Size:278
Attachment: demo-pointers.ecf     Size:1406
Attachment: external.txt     Size:11888