* [Bug fortran/104128] ICE in gfc_widechar_to_char, at fortran/scanner.c:199
2022-01-19 18:51 [Bug fortran/104128] New: ICE in gfc_widechar_to_char, at fortran/scanner.c:199 gscfq@t-online.de
@ 2022-01-19 19:29 ` anlauf at gcc dot gnu.org
2022-01-19 21:24 ` anlauf at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-19 19:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104128
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
CC| |anlauf at gcc dot gnu.org
Ever confirmed|0 |1
Last reconfirmed| |2022-01-19
--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/104128] ICE in gfc_widechar_to_char, at fortran/scanner.c:199
2022-01-19 18:51 [Bug fortran/104128] New: ICE in gfc_widechar_to_char, at fortran/scanner.c:199 gscfq@t-online.de
2022-01-19 19:29 ` [Bug fortran/104128] " anlauf at gcc dot gnu.org
@ 2022-01-19 21:24 ` anlauf at gcc dot gnu.org
2022-01-21 20:48 ` anlauf at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-19 21:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104128
--- Comment #2 from anlauf at gcc dot gnu.org ---
Tentative, semi-obvious patch:
diff --git a/gcc/fortran/target-memory.cc b/gcc/fortran/target-memory.cc
index 361907b0e51..7ce7d736629 100644
--- a/gcc/fortran/target-memory.cc
+++ b/gcc/fortran/target-memory.cc
@@ -365,7 +365,8 @@ gfc_target_encode_expr (gfc_expr *source, unsigned char
*buffer,
static size_t
-interpret_array (unsigned char *buffer, size_t buffer_size, gfc_expr *result)
+interpret_array (unsigned char *buffer, size_t buffer_size, gfc_expr *result,
+ bool convert_widechar)
{
gfc_constructor_base base = NULL;
size_t array_size = 1;
@@ -390,7 +391,7 @@ interpret_array (unsigned char *buffer, size_t buffer_size,
gfc_expr *result)
gfc_constructor_append_expr (&base, e, &result->where);
ptr += gfc_target_interpret_expr (&buffer[ptr], buffer_size - ptr, e,
- true);
+ convert_widechar);
}
result->value.constructor = base;
@@ -580,7 +581,7 @@ gfc_target_interpret_expr (unsigned char *buffer, size_t
buffer_size,
gfc_expr *result, bool convert_widechar)
{
if (result->expr_type == EXPR_ARRAY)
- return interpret_array (buffer, buffer_size, result);
+ return interpret_array (buffer, buffer_size, result, convert_widechar);
switch (result->ts.type)
{
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/104128] ICE in gfc_widechar_to_char, at fortran/scanner.c:199
2022-01-19 18:51 [Bug fortran/104128] New: ICE in gfc_widechar_to_char, at fortran/scanner.c:199 gscfq@t-online.de
2022-01-19 19:29 ` [Bug fortran/104128] " anlauf at gcc dot gnu.org
2022-01-19 21:24 ` anlauf at gcc dot gnu.org
@ 2022-01-21 20:48 ` anlauf at gcc dot gnu.org
2022-01-21 20:49 ` anlauf at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-21 20:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104128
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
Keywords| |wrong-code
--- Comment #3 from anlauf at gcc dot gnu.org ---
The patch in comment#2 fixes the ICE in comment#0, but uncovers a few issues
with TRANSFER between different integer kinds. E.g.
program p
implicit none
character(kind=4,len=2), parameter :: z = 4_"FG"
character(kind=1,len=*), parameter :: x = transfer (z, 'abcdefgh')
character(kind=4,len=*), parameter :: v = transfer (x, z)
print *, z
print *, v
if (v /= z) stop 3
end
shows that we do not get a clean round-trip.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/104128] ICE in gfc_widechar_to_char, at fortran/scanner.c:199
2022-01-19 18:51 [Bug fortran/104128] New: ICE in gfc_widechar_to_char, at fortran/scanner.c:199 gscfq@t-online.de
` (2 preceding siblings ...)
2022-01-21 20:48 ` anlauf at gcc dot gnu.org
@ 2022-01-21 20:49 ` anlauf at gcc dot gnu.org
2022-01-21 22:06 ` anlauf at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-21 20:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104128
--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #3)
> with TRANSFER between different integer kinds. E.g.
oops, that should read: character kinds
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/104128] ICE in gfc_widechar_to_char, at fortran/scanner.c:199
2022-01-19 18:51 [Bug fortran/104128] New: ICE in gfc_widechar_to_char, at fortran/scanner.c:199 gscfq@t-online.de
` (3 preceding siblings ...)
2022-01-21 20:49 ` anlauf at gcc dot gnu.org
@ 2022-01-21 22:06 ` anlauf at gcc dot gnu.org
2022-01-23 20:07 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-21 22:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104128
--- Comment #5 from anlauf at gcc dot gnu.org ---
The issue in comment#3 is likely unrelated to TRANSFER:
program p
implicit none
! integer, parameter :: k = 1
integer, parameter :: k = 4
character(kind=k,len=2), parameter :: z = k_"FG"
character(kind=1,len=*), parameter :: x = transfer (z, 'abcdefgh')
character(kind=k,len=2) :: u = transfer (x, z) ! always OK
character(kind=k,len=2), parameter :: v = transfer (x, z) ! OK (kind=1)
logical, parameter :: l = (z == v)
print *, "z == v:", l
print *, z
print *, u
if (u /= z) stop 4
print *, v
if (v /= z) stop 3 ! stops here for kind=4
end
This works for k=1 (z==v), but fails for k=4 (z/=v, but should be same).
(NAG confirms my expectations.)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/104128] ICE in gfc_widechar_to_char, at fortran/scanner.c:199
2022-01-19 18:51 [Bug fortran/104128] New: ICE in gfc_widechar_to_char, at fortran/scanner.c:199 gscfq@t-online.de
` (4 preceding siblings ...)
2022-01-21 22:06 ` anlauf at gcc dot gnu.org
@ 2022-01-23 20:07 ` anlauf at gcc dot gnu.org
2022-01-23 21:09 ` anlauf at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-23 20:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104128
--- Comment #6 from anlauf at gcc dot gnu.org ---
The remaining issues in this PR seem to be related to inconsistencies
between expr->representation.string and expr->value.character.string
that occur for non-default character kind that are created in gfc_copy_expr.
Hackish fix to avoid converting the (bytewise) representation.string for
non-default character kind:
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 279d9b30991..ed82a94022f 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -312,7 +312,8 @@ gfc_copy_expr (gfc_expr *p)
break;
case BT_CHARACTER:
- if (p->representation.string)
+ if (p->representation.string
+ && p->ts.kind == gfc_default_character_kind)
q->value.character.string
= gfc_char_to_widechar (q->representation.string);
else
Needs regtesting.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/104128] ICE in gfc_widechar_to_char, at fortran/scanner.c:199
2022-01-19 18:51 [Bug fortran/104128] New: ICE in gfc_widechar_to_char, at fortran/scanner.c:199 gscfq@t-online.de
` (5 preceding siblings ...)
2022-01-23 20:07 ` anlauf at gcc dot gnu.org
@ 2022-01-23 21:09 ` anlauf at gcc dot gnu.org
2022-01-27 19:39 ` cvs-commit at gcc dot gnu.org
2022-01-27 19:40 ` anlauf at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-23 21:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104128
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #7 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2022-January/057437.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/104128] ICE in gfc_widechar_to_char, at fortran/scanner.c:199
2022-01-19 18:51 [Bug fortran/104128] New: ICE in gfc_widechar_to_char, at fortran/scanner.c:199 gscfq@t-online.de
` (6 preceding siblings ...)
2022-01-23 21:09 ` anlauf at gcc dot gnu.org
@ 2022-01-27 19:39 ` cvs-commit at gcc dot gnu.org
2022-01-27 19:40 ` anlauf at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-27 19:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104128
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:b51fb28ed294cdf19087ca9d9ad107c9c52bec42
commit r12-6902-gb51fb28ed294cdf19087ca9d9ad107c9c52bec42
Author: Harald Anlauf <anlauf@gmx.de>
Date: Sun Jan 23 21:55:33 2022 +0100
Fortran: fix issues with internal conversion between default and wide char
gcc/fortran/ChangeLog:
PR fortran/104128
* expr.cc (gfc_copy_expr): Convert internal representation of
string to wide char in value only for default character kind.
* target-memory.cc (interpret_array): Pass flag for conversion of
wide chars.
(gfc_target_interpret_expr): Likewise.
gcc/testsuite/ChangeLog:
PR fortran/104128
* gfortran.dg/transfer_simplify_14.f90: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/104128] ICE in gfc_widechar_to_char, at fortran/scanner.c:199
2022-01-19 18:51 [Bug fortran/104128] New: ICE in gfc_widechar_to_char, at fortran/scanner.c:199 gscfq@t-online.de
` (7 preceding siblings ...)
2022-01-27 19:39 ` cvs-commit at gcc dot gnu.org
@ 2022-01-27 19:40 ` anlauf at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-27 19:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104128
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Target Milestone|--- |12.0
--- Comment #9 from anlauf at gcc dot gnu.org ---
Fixed for gcc-12. Closing.
Thanks for the report!
^ permalink raw reply [flat|nested] 10+ messages in thread