This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/32732] New: [Bind C] Character scalars are passed as arrays


|  subroutine foo(a) bind(c)
|    character(len=1,kind=c_char), value :: a

Has a single, scalar argument a; in C notation:
| void foo(char a)

gfortran, however, uses
| void foo(char a[]) 
with length one.

This causes problems on IA-64 HP-UX, see thread starting at
http://gcc.gnu.org/ml/fortran/2007-07/msg00210.html

(If "a" is a scalar, one needs to audit also all character uses to make sure
that one does use it as such (and does not compile Fortran "if(a /= 5)" into C
"if(*a != 5) as "a" is not a pointer.)



Additionally, If the function is called, the length is additionally passed to
the function:
| call foo("a")
produces:
| foo("a", 1) // 'a' array, not zero terminated
instead of
| foo('a')

As the length arguments come always last and are not used, this seems to be
harmless, but there might be platforms or scenarios where they may cause
problems.


-- 
           Summary: [Bind C] Character scalars are passed as arrays
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org
OtherBugsDependingO 32630
             nThis:


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32732


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]