https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109322
Bug ID: 109322
Summary: -fc-prototypes does not correctly translate
INTEGER(KIND=C_SIZE_T), and other sizes
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: emr-gnu at hev dot psu.edu
Target Milestone: ---
When generating C-prototypes, the gfortran compiler translates stdint.h
typedefs to their destination types at invocation time, rather than leaving
that to the C/C++ compiler in the translated code. Example: C_SIZE_T is
translated to "long" rather than "size_t" in the generated prototype
structures. This holds true for function parameters and return values as well.
foo.f90:
MODULE FOO
USE, INTRINSIC :: ISO_C_BINDING
IMPLICIT NONE
PUBLIC :: BAR
TYPE, BIND(C) :: BAR
INTEGER(KIND=C_SIZE_T) :: A = -1
INTEGER(KIND=C_INT32_T) :: B = -1
INTEGER(KIND=C_INT16_T) :: C = -1
INTEGER(KIND=C_INT8_T) :: D = -1
END TYPE
END MODULE
The above produces the following output:
> gfortran -fc-prototypes -fsyntax-only foo.f90
typedef struct bar {
long a;
int b;
short c;
signed char d;
} bar;
--------------
Expected output:
typedef struct bar {
size_t a;
int32_t b;
int16_t c;
int8_t d;
} bar;