Hi!

This PR is about ASAN failing with checking failures.  The problem is
on the Fortran FE side, which calls BUILT_IN_MEMCPY sometimes with wrong
type of the last argument (which is not type compatible with the
size_type_node type).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2012-11-17  Jakub Jelinek  <ja...@redhat.com>

        PR fortran/55341
        * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Convert last
        argument to memcpy to size_type_node type.
        * trans-stmt.c (gfc_conv_elemental_dependencies): Likewise.
        * trasn-array.c (duplicate_allocatable): Likewise.

--- gcc/fortran/trans-intrinsic.c.jj    2012-11-06 12:21:17.000000000 +0100
+++ gcc/fortran/trans-intrinsic.c       2012-11-16 11:48:14.111974090 +0100
@@ -5600,14 +5600,16 @@ gfc_conv_intrinsic_transfer (gfc_se * se
   tmp = fold_convert (pvoid_type_node, tmp);
 
   /* Use memcpy to do the transfer.  */
-  tmp = build_call_expr_loc (input_location,
-                        builtin_decl_explicit (BUILT_IN_MEMCPY),
-                        3,
-                        tmp,
-                        fold_convert (pvoid_type_node, source),
-                        fold_build2_loc (input_location, MIN_EXPR,
-                                         gfc_array_index_type,
-                                         size_bytes, source_bytes));
+  tmp
+    = build_call_expr_loc (input_location,
+                          builtin_decl_explicit (BUILT_IN_MEMCPY), 3, tmp,
+                          fold_convert (pvoid_type_node, source),
+                          fold_convert (size_type_node,
+                                        fold_build2_loc (input_location,
+                                                         MIN_EXPR,
+                                                         gfc_array_index_type,
+                                                         size_bytes,
+                                                         source_bytes)));
   gfc_add_expr_to_block (&se->pre, tmp);
 
   se->expr = info->descriptor;
@@ -5649,7 +5651,7 @@ scalar_transfer:
                             builtin_decl_explicit (BUILT_IN_MEMCPY), 3,
                             fold_convert (pvoid_type_node, tmpdecl),
                             fold_convert (pvoid_type_node, ptr),
-                            extent);
+                            fold_convert (size_type_node, extent));
       gfc_add_expr_to_block (&block, tmp);
       indirect = gfc_finish_block (&block);
 
@@ -5687,7 +5689,7 @@ scalar_transfer:
                             builtin_decl_explicit (BUILT_IN_MEMCPY), 3,
                             fold_convert (pvoid_type_node, tmp),
                             fold_convert (pvoid_type_node, ptr),
-                            extent);
+                            fold_convert (size_type_node, extent));
       gfc_add_expr_to_block (&se->pre, tmp);
 
       /* For CLASS results, set the _vptr.  */
--- gcc/fortran/trans-stmt.c.jj 2012-10-17 17:18:21.000000000 +0200
+++ gcc/fortran/trans-stmt.c    2012-11-16 11:45:26.608192584 +0100
@@ -337,7 +337,8 @@ gfc_conv_elemental_dependencies (gfc_se
              tmp = gfc_conv_descriptor_data_get (tmp);
              tmp = build_call_expr_loc (input_location,
                                         builtin_decl_explicit 
(BUILT_IN_MEMCPY),
-                                        3, tmp, data, size);
+                                        3, tmp, data,
+                                        fold_convert (size_type_node, size));
            }
          gfc_add_expr_to_block (&se->post, tmp);
 
--- gcc/fortran/trans-array.c.jj        2012-11-01 09:33:28.000000000 +0100
+++ gcc/fortran/trans-array.c   2012-11-16 11:49:46.875541899 +0100
@@ -7341,8 +7341,8 @@ duplicate_allocatable (tree dest, tree s
        }
 
       tmp = builtin_decl_explicit (BUILT_IN_MEMCPY);
-      tmp = build_call_expr_loc (input_location, tmp, 3,
-                                dest, src, size);
+      tmp = build_call_expr_loc (input_location, tmp, 3, dest, src,
+                                fold_convert (size_type_node, size));
     }
   else
     {
@@ -7367,7 +7367,8 @@ duplicate_allocatable (tree dest, tree s
       tmp = builtin_decl_explicit (BUILT_IN_MEMCPY);
       tmp = build_call_expr_loc (input_location,
                        tmp, 3, gfc_conv_descriptor_data_get (dest),
-                       gfc_conv_descriptor_data_get (src), size);
+                       gfc_conv_descriptor_data_get (src),
+                       fold_convert (size_type_node, size));
     }
 
   gfc_add_expr_to_block (&block, tmp);

        Jakub

Reply via email to