* [Patch, Fortran] PR54818 - Fix ICE with TRANSFER to char
@ 2012-12-19 23:29 Tobias Burnus
2012-12-19 23:59 ` Paul Richard Thomas
0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2012-12-19 23:29 UTC (permalink / raw)
To: gcc patches, gfortran
[-- Attachment #1: Type: text/plain, Size: 242 bytes --]
TRANSFER(..., "string") created on x86-64 an integer(8) string length;
that lead to a tree-checking ICE but also might pass the wrong type in
'call sub(transfer(233," ")'.
Build and regtested on x86-64-gnu-linux.
OK for the trunk?
Tobias
[-- Attachment #2: transfer-strlen.diff --]
[-- Type: text/x-patch, Size: 1692 bytes --]
2012-12-20 Tobias Burnus <burnus@net-b.de>
PR fortran/54818
* trans-intrinsic.c (gfc_conv_intrinsic_transfer): Ensure that
the string length if of type gfc_charlen_type_node.
2012-12-20 Tobias Burnus <burnus@net-b.de>
PR fortran/54818
* gfortran.dg/transfer_intrinsic_4.f: New.
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 4f74c3f..b1e6a2e 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -5662,7 +5662,7 @@ scalar_transfer:
gfc_add_expr_to_block (&se->pre, tmp);
se->expr = tmpdecl;
- se->string_length = dest_word_len;
+ se->string_length = fold_convert (gfc_charlen_type_node, dest_word_len);
}
else
{
diff --git a/gcc/testsuite/gfortran.dg/transfer_intrinsic_4.f b/gcc/testsuite/gfortran.dg/transfer_intrinsic_4.f
new file mode 100644
index 0000000..4173afd
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/transfer_intrinsic_4.f
@@ -0,0 +1,27 @@
+! { dg-do compile }
+!
+! PR fortran/54818
+!
+! Contributed by Scott Pakin
+!
+ subroutine broken ( name1, name2, bmix )
+
+ implicit none
+
+ integer, parameter :: i_knd = kind( 1 )
+ integer, parameter :: r_knd = selected_real_kind( 13 )
+
+ character(len=8) :: dum
+ character(len=8) :: blk
+ real(r_knd), dimension(*) :: bmix, name1, name2
+ integer(i_knd) :: j, idx1, n, i
+ integer(i_knd), external :: nafix
+
+ write (*, 99002) name1(j),
+ & ( adjustl(
+ & transfer(name2(nafix(bmix(idx1+i),1)),dum)//blk
+ & //blk), bmix(idx1+i+1), i = 1, n, 2 )
+
+99002 format (' *', 10x, a8, 8x, 3(a24,1pe12.5,',',6x))
+
+ end subroutine broken
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch, Fortran] PR54818 - Fix ICE with TRANSFER to char
2012-12-19 23:29 [Patch, Fortran] PR54818 - Fix ICE with TRANSFER to char Tobias Burnus
@ 2012-12-19 23:59 ` Paul Richard Thomas
0 siblings, 0 replies; 2+ messages in thread
From: Paul Richard Thomas @ 2012-12-19 23:59 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc patches, gfortran
Dear Tobias,
OK for trunk, apart from:
s/the string length if of type gfc_charlen_type_node/the string length
is of type gfc_charlen_type_node/
Thanks for the patch
Paul
On 20 December 2012 00:29, Tobias Burnus <burnus@net-b.de> wrote:
> TRANSFER(..., "string") created on x86-64 an integer(8) string length; that
> lead to a tree-checking ICE but also might pass the wrong type in 'call
> sub(transfer(233," ")'.
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
>
> Tobias
--
The knack of flying is learning how to throw yourself at the ground and miss.
--Hitchhikers Guide to the Galaxy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-12-19 23:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-19 23:29 [Patch, Fortran] PR54818 - Fix ICE with TRANSFER to char Tobias Burnus
2012-12-19 23:59 ` Paul Richard Thomas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).