------- Comment #1 from burnus at gcc dot gnu dot org  2010-02-10 10:35 -------
Confirm - and thanks for the report!

For non-BIND(C), Fortran passes a hidden argument with the string length thus
one can add a bounds check check:
  if (expected_length > passed_length)
    print_bound_error
Expected size is here "1" but for BIND(C) there is no hidden argument with the
string length; thus, the compiler crashes.

The following patch should fix it.

Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c    (revision 156647)
+++ gcc/fortran/trans-decl.c    (working copy)
@@ -4367,7 +4370,7 @@ gfc_generate_function_code (gfc_namespac
   /* If bounds-checking is enabled, generate code to check passed in actual
      arguments against the expected dummy argument attributes (e.g. string
      lengths).  */
-  if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
+  if ((gfc_option.rtcheck & GFC_RTCHECK_BOUNDS) && !sym->attr.is_bind_c)
     add_argument_checking (&body, sym);

   tmp = gfc_trans_code (ns->code);


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |burnus at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   GCC host triplet|i686-pc-linux               |
 GCC target triplet|x86_64-w64-mingw32          |
           Keywords|                            |ice-on-valid-code
      Known to fail|                            |4.5.0
      Known to work|                            |4.4.3
   Last reconfirmed|0000-00-00 00:00:00         |2010-02-10 10:35:14
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43015

Reply via email to