public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/109322] New: -fc-prototypes does not correctly translate INTEGER(KIND=C_SIZE_T), and other sizes
@ 2023-03-28 21:20 emr-gnu at hev dot psu.edu
  2023-03-29 17:13 ` [Bug fortran/109322] " kargl at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: emr-gnu at hev dot psu.edu @ 2023-03-28 21:20 UTC (permalink / raw)
  To: gcc-bugs

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;

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-03-30 20:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 21:20 [Bug fortran/109322] New: -fc-prototypes does not correctly translate INTEGER(KIND=C_SIZE_T), and other sizes emr-gnu at hev dot psu.edu
2023-03-29 17:13 ` [Bug fortran/109322] " kargl at gcc dot gnu.org
2023-03-29 17:50 ` emr-gnu at hev dot psu.edu
2023-03-29 19:42 ` sgk at troutmask dot apl.washington.edu
2023-03-29 21:24 ` pinskia at gcc dot gnu.org
2023-03-29 21:28 ` pinskia at gcc dot gnu.org
2023-03-29 21:30 ` pinskia at gcc dot gnu.org
2023-03-29 21:45 ` sgk at troutmask dot apl.washington.edu
2023-03-29 21:47 ` pinskia at gcc dot gnu.org
2023-03-30 19:02 ` sgk at troutmask dot apl.washington.edu
2023-03-30 19:21 ` pinskia at gcc dot gnu.org
2023-03-30 20:10 ` sgk at troutmask dot apl.washington.edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).