From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3948 invoked by alias); 11 Jul 2007 21:20:33 -0000 Received: (qmail 3907 invoked by uid 48); 11 Jul 2007 21:20:22 -0000 Date: Wed, 11 Jul 2007 21:20:00 -0000 Subject: [Bug fortran/32732] New: [Bind C] Character scalars are passed as arrays X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-07/txt/msg01327.txt.bz2 | 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