This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/32732] New: [Bind C] Character scalars are passed as arrays
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jul 2007 21:20:22 -0000
- Subject: [Bug fortran/32732] New: [Bind C] Character scalars are passed as arrays
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
| 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