From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31830 invoked by alias); 16 Nov 2010 08:56:42 -0000 Received: (qmail 31818 invoked by uid 22791); 16 Nov 2010 08:56:40 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 16 Nov 2010 08:56:36 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/46496] New: Missing strlen check / interop warnings with BIND(C) and non-C_* kinds X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: accepts-invalid, diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 16 Nov 2010 09:14:00 -0000 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: 2010-11/txt/msg02021.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46496 Summary: Missing strlen check / interop warnings with BIND(C) and non-C_* kinds Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: accepts-invalid, diagnostic Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org (a) is a wording nit (by Richard Main) (b) be able to turn off the warning (common request by Richard Main et al.) (c) to (e) are warning inconsistencies (examples by James Van Buskirk) (f) is a missing constraint check (examples by James Van Buskirk) gfortran warns if one does not use kind= where is a constant defined in ISO_C_BINDING or a constant which has been derived from it by direct assignment. I think that's OK, however, many do not like it as one can see, e.g., at http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/44d572766bce0e6f a) The warning should use "dummy argument" and not the C-speak "parameter": "Variable 'x' at (1) is a parameter to the BIND(C) procedure 'all_subs' but may not be C interoperable" b) There should be some way to turn off this warning (and only this one) - currently it is enabled by default and can only be turned of by "-w" which silents all warnings. c) One should consider allowing: KIND(variable/parameter with the bind-c-compatible kind) Currently, using such a kind parameter gives a warning, e.g. for module mytypes use ISO_C_BINDING implicit none private public T type, bind(C) :: T character(len=1,kind=kind(C_CHAR_'A')) item ! kind=KIND(): Gives warning end type T end module mytypes d) The following should show a warning as one sets the LEN= and not the KIND= parameter; the len=C_char is OK, but the kind=c_char is missing. module mytypes use ISO_C_BINDING implicit none private public T type, bind(C) :: T character(C_CHAR) item ! len=c_char: Warning is missing end type T end module mytypes e) Ditto for: module mytypes use ISO_C_BINDING implicit none private public T type, bind(C) :: T character*(C_CHAR), item end type T end module mytypes f) The following two examples are invalid - but seemingly gfortran does not check the string length of DT character components: module mytypes use ISO_C_BINDING implicit none private public T type, bind(C) :: T character(len=2,kind=C_CHAR) item ! INVALID length: 2 end type T end module mytypes module mytypes use ISO_C_BINDING implicit none private public T type, bind(C) :: T character(len=*,kind=C_CHAR) item*(2) ! INVALID length of 2 end type T end module mytypes