diff mbox series

[fortran] : Do not cast charlen to index type in transfer_array_inner

Message ID CAFULd4Z3U8EL2k=vQq36c5=W6SkewHmA=2Y9m1jLt59vSMkeOA@mail.gmail.com
State New
Headers show
Series [fortran] : Do not cast charlen to index type in transfer_array_inner | expand

Commit Message

Uros Bizjak Feb. 26, 2019, 6:16 p.m. UTC
Attached patch removes following warning:

libgfortran/io/transfer.c: In function ‘transfer_array_inner’:
libgfortran/io/transfer.c:2499:35: warning: operand of ?: changes
signedness from ‘long int’ to ‘size_t’ {aka ‘long unsigned int’} due
to unsignedness of other operand [-Wsign-compare]

There is actually no need to cast "charlen" to (unsigned) index_type,
as it is already declared as size_t:

typedef size_t gfc_charlen_type;

the same type as are "elem_len" and "size" variables.

2019-02-26  Uroš Bizjak  <ubizjak@gmail.com>

    * io/transfer.c (transfer_array_inner): Do not
    cast charlen to index type.

Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

OK for mainline?

Uros.

Comments

Steve Kargl Feb. 26, 2019, 6:32 p.m. UTC | #1
On Tue, Feb 26, 2019 at 07:16:21PM +0100, Uros Bizjak wrote:
> Attached patch removes following warning:
> 
> libgfortran/io/transfer.c: In function ‘transfer_array_inner’:
> libgfortran/io/transfer.c:2499:35: warning: operand of ?: changes
> signedness from ‘long int’ to ‘size_t’ {aka ‘long unsigned int’} due
> to unsignedness of other operand [-Wsign-compare]
> 
> There is actually no need to cast "charlen" to (unsigned) index_type,
> as it is already declared as size_t:
> 
> typedef size_t gfc_charlen_type;
> 
> the same type as are "elem_len" and "size" variables.
> 
> 2019-02-26  Uroš Bizjak  <ubizjak@gmail.com>
> 
>     * io/transfer.c (transfer_array_inner): Do not
>     cast charlen to index type.
> 
> Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
> 
> OK for mainline?
> 

Yes.
diff mbox series

Patch

Index: io/transfer.c
===================================================================
--- io/transfer.c	(revision 269217)
+++ io/transfer.c	(working copy)
@@ -2496,7 +2496,7 @@  transfer_array_inner (st_parameter_dt *dtp, gfc_ar
     return;
 
   iotype = (bt) GFC_DESCRIPTOR_TYPE (desc);
-  size = iotype == BT_CHARACTER ? (index_type) charlen : GFC_DESCRIPTOR_SIZE (desc);
+  size = iotype == BT_CHARACTER ? charlen : GFC_DESCRIPTOR_SIZE (desc);
 
   rank = GFC_DESCRIPTOR_RANK (desc);