https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84885
--- Comment #5 from mdblack98 at yahoo dot com --- I've been using Fortran since 1980 so caps is natural to me :-) My concern is that if gfortran has supported the len>1 convention for many years than perhaps it should continue supporting it to prevent breaking code like ours which will take some major effort to rewrite.Consider it an "extension" to gfortran which apparently it was. Still fully 2018 compliant with this one little extension. Enable it via a switch if you want to. Making it a char array of 10 does not solve the problem as it doesn't behave the same. Maybe it should behave the same? Here's my test Both gcc-7 and gcc-8 work fine without the "type" block. So comment out the type and end type lines and you get the correct output.But including the type block causes both gcc-7 and gcc-8 to print out a floating point number instead of the char string. So the data type when inside the type block is different than when it's outside the type block? Or is there some logical difference between len=1 c(10) and len=10 c? #include <stdio.h> #include <string.h> void foo_(int *i,char *c,int); int main() { int i=123; char c[11]; sprintf(c,"%s","1234567890"); foo_(&i,c,strlen(c)); return 0; } subroutine foo(i,c) use, intrinsic :: iso_c_binding, only: c_int,c_char,c_long type, bind(C):: params_block integer(c_int) :: i character(kind=c_char,len=1) :: c(10) end type params_block write(*,*) 'Testing' write(*,*) i write(*,*) c end Mike On Thursday, March 15, 2018, 5:58:21 PM CDT, sgk at troutmask dot apl.washington.edu <gcc-bugzi...@gcc.gnu.org> wrote: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84885 --- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Thu, Mar 15, 2018 at 09:57:08PM +0000, mdblack98 at yahoo dot com wrote: > > --- Comment #3 from mdblack98 at yahoo dot com --- > I'll correct my reply in that using len > 1 outside of an interoperability > block is OK. > > So it is apparently now impossible to declare c_char len > 1 inside such a > block? > Steve Lionel is correct. If you have a BIND(C) entity and it involves the character type, then the length parameter must be 1. I quoted from a draft of the upcoming F2018, because that is what I had at hand. The Fortran 2003 standard has essentially the same language: F2003, page 398 A Fortran derived type is interoperable with a C struct type if the derived-type definition of the Fortran type specifies BIND(C) (4.5.1), the Fortran derived type and the C struct type have the same number of components, and the components of the Fortran derived type have types and type parameters that are interoperable with the types of the corresponding components of the struct type. Fortran 2003, page 396 ...; if the type is character, interoperability also requires that the length type parameter be omitted or be specified by an initialization expression whose value is one. You can specify an array of characters, e.g., type, bind(c) :: foo character(kind=c_char, len=1) :: c(10) end type foo PS: The name of the language is Fortran. It hasn't been written in all capital letters since 1990.