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: unassig...@gcc.gnu.org
        ReportedBy: bur...@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=<c>
where <c> 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

Reply via email to