public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/32732]  New: [Bind C] Character scalars are passed as arrays
@ 2007-07-11 21:20 burnus at gcc dot gnu dot org
  2007-07-18 18:11 ` [Bug fortran/32732] " patchapp at dberlin dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-07-11 21:20 UTC (permalink / raw)
  To: gcc-bugs

|  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


^ permalink raw reply	[flat|nested] 8+ messages in thread
[parent not found: <bug-32732-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2021-12-26 17:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-11 21:20 [Bug fortran/32732] New: [Bind C] Character scalars are passed as arrays burnus at gcc dot gnu dot org
2007-07-18 18:11 ` [Bug fortran/32732] " patchapp at dberlin dot org
2007-07-23  9:03 ` burnus at gcc dot gnu dot org
2007-07-23  9:08 ` burnus at gcc dot gnu dot org
2007-07-25 22:56 ` sje at cup dot hp dot com
2007-08-07  0:27 ` kargl at gcc dot gnu dot org
2007-08-07  0:29 ` kargl at gcc dot gnu dot org
     [not found] <bug-32732-4@http.gcc.gnu.org/bugzilla/>
2021-12-26 17:39 ` fxcoudert at gcc dot gnu.org

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).