public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
@ 2020-06-28 14:28 urbanjost at comcast dot net
2020-06-28 14:34 ` [Bug fortran/95947] " urbanjost at comcast dot net
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: urbanjost at comcast dot net @ 2020-06-28 14:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
Bug ID: 95947
Summary: PACK intrinsic returns blank strings when an
allocatable character array with allocatable length is
used
Product: gcc
Version: 8.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: urbanjost at comcast dot net
Target Milestone: ---
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
@ 2020-06-28 14:34 ` urbanjost at comcast dot net
2020-06-28 21:20 ` urbanjost at comcast dot net
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: urbanjost at comcast dot net @ 2020-06-28 14:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
--- Comment #1 from urbanjost at comcast dot net ---
Created attachment 48796
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48796&action=edit
test using PACK(3f) intrinsic with allocatable variables
PACK() intrinsic is returning all blanks in subroutine BAD3().
Expect all three test routines to produce "bat cat"; but third one produces
blanks, Seems to occur only with len=: variable(?)
gfortran xbad.f90
bash-4.4$ ./a.out
bat cat
bat cat
10 4
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
2020-06-28 14:34 ` [Bug fortran/95947] " urbanjost at comcast dot net
@ 2020-06-28 21:20 ` urbanjost at comcast dot net
2020-07-07 13:48 ` dominiq at lps dot ens.fr
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: urbanjost at comcast dot net @ 2020-06-28 21:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
--- Comment #2 from urbanjost at comcast dot net ---
Per feedback made test more like a unit test:
TEST PROGRAM:
character(len=:),allocatable :: m(:) !!NOTE: WORKS WITH len=10 instead of
len=:
logical :: passed
m = [ character(len=10) :: 'ape','bat','cat','dog','eel','fly','gnu']
m = pack( m, mask=m(:)(2:2) == 'a' )
print *, "m = ", m, "; expected is ['bat','cat']"
passed=all(m.eq.['bat','cat'])
print *, "size(m) = ", size(m), "; expected is 2"
passed=size(m).eq.2.and.passed
print *, "len(m) = ", len(m), "; expected is 10"
passed=len(m).eq.10.and.passed
print *, "len_trim(m) = ", len_trim(m), "; expected is 3 3"
passed=all(len_trim(m).eq.[3,3]).and.passed
if(passed)then
stop 'PASSED'
else
write(*,'("FAILED")')
stop 1
endif
end
RESULTS:
m = ; expected is ['bat','cat']
size(m) = 2 ; expected is 2
len(m) = 10 ; expected is 10
len_trim(m) = 0 0 ; expected is 3 3
FAILED
STOP 1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
2020-06-28 14:34 ` [Bug fortran/95947] " urbanjost at comcast dot net
2020-06-28 21:20 ` urbanjost at comcast dot net
@ 2020-07-07 13:48 ` dominiq at lps dot ens.fr
2022-12-14 14:39 ` urbanjost at comcast dot net
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-07-07 13:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-07-07
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed from at least GCC5.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
` (2 preceding siblings ...)
2020-07-07 13:48 ` dominiq at lps dot ens.fr
@ 2022-12-14 14:39 ` urbanjost at comcast dot net
2022-12-14 20:28 ` anlauf at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: urbanjost at comcast dot net @ 2022-12-14 14:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
--- Comment #4 from urbanjost at comcast dot net ---
FYI: Still occurs in 12.2.0.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
` (3 preceding siblings ...)
2022-12-14 14:39 ` urbanjost at comcast dot net
@ 2022-12-14 20:28 ` anlauf at gcc dot gnu.org
2022-12-14 20:54 ` anlauf at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-14 20:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
--- Comment #5 from anlauf at gcc dot gnu.org ---
The dump tree shows near the pack intrinsic:
- for character(len=10):
atmp.4.dtype = {.elem_len=10, .rank=1, .type=6};
atmp.4.span = 10;
atmp.4.data = 0B;
atmp.4.offset = 0;
_gfortran_pack_char (&atmp.4, 10, D.4308, D.4328, 0B, 10, 0);
- for character(len=:):
atmp.5.dtype = {.elem_len=(unsigned long) slen.4, .rank=1, .type=6};
atmp.5.span = (integer(kind=8)) SAVE_EXPR <(sizetype) NON_LVALUE_EXPR
<slen.4>>;
atmp.5.data = 0B;
atmp.5.offset = 0;
slen.4 = 0;
_gfortran_pack_char (&atmp.5, &slen.4, D.4314, D.4334, 0B, .n, 0);
So we seem to clobber the string length before calling pack.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
` (4 preceding siblings ...)
2022-12-14 20:28 ` anlauf at gcc dot gnu.org
@ 2022-12-14 20:54 ` anlauf at gcc dot gnu.org
2023-07-17 18:49 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-14 20:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
--- Comment #6 from anlauf at gcc dot gnu.org ---
Setting a breakpoint in gfc_resolve_pack, I find for the len=: case:
(gdb) p *array->ts.u.cl
$12 = {length = 0x0, next = 0x2cc7af0, length_from_typespec = false,
backend_decl = 0x0,
passed_length = 0x0, resolved = 1}
Not good.
I see similar problems for other intrinsics, such as in:
m = adjustl (m([2]))
which later ICEs...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
` (5 preceding siblings ...)
2022-12-14 20:54 ` anlauf at gcc dot gnu.org
@ 2023-07-17 18:49 ` cvs-commit at gcc dot gnu.org
2023-07-18 18:40 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-17 18:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
--- Comment #7 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:95ddd2659849a904509067ec3a2770135149a722
commit r14-2586-g95ddd2659849a904509067ec3a2770135149a722
Author: Harald Anlauf <anlauf@gmx.de>
Date: Sun Jul 16 22:17:27 2023 +0200
Fortran: intrinsics and deferred-length character arguments
[PR95947,PR110658]
gcc/fortran/ChangeLog:
PR fortran/95947
PR fortran/110658
* trans-expr.cc (gfc_conv_procedure_call): For intrinsic procedures
whose result characteristics depends on the first argument and
which
can be of type character, the character length will not be
deferred.
gcc/testsuite/ChangeLog:
PR fortran/95947
PR fortran/110658
* gfortran.dg/deferred_character_37.f90: New test.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
` (6 preceding siblings ...)
2023-07-17 18:49 ` cvs-commit at gcc dot gnu.org
@ 2023-07-18 18:40 ` cvs-commit at gcc dot gnu.org
2023-07-18 18:45 ` anlauf at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-18 18:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:ccf94ab2abb6969c04d51c7879f07edfbb97ae55
commit r13-7584-gccf94ab2abb6969c04d51c7879f07edfbb97ae55
Author: Harald Anlauf <anlauf@gmx.de>
Date: Sun Jul 16 22:17:27 2023 +0200
Fortran: intrinsics and deferred-length character arguments
[PR95947,PR110658]
gcc/fortran/ChangeLog:
PR fortran/95947
PR fortran/110658
* trans-expr.cc (gfc_conv_procedure_call): For intrinsic procedures
whose result characteristics depends on the first argument and
which
can be of type character, the character length will not be
deferred.
gcc/testsuite/ChangeLog:
PR fortran/95947
PR fortran/110658
* gfortran.dg/deferred_character_37.f90: New test.
(cherry picked from commit 95ddd2659849a904509067ec3a2770135149a722)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
` (7 preceding siblings ...)
2023-07-18 18:40 ` cvs-commit at gcc dot gnu.org
@ 2023-07-18 18:45 ` anlauf at gcc dot gnu.org
2023-07-20 18:56 ` cvs-commit at gcc dot gnu.org
2023-07-20 19:06 ` cvs-commit at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-07-18 18:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |anlauf at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #9 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-14 so far, and on 13-branch.
Might be backported further after waiting some time.
Thanks for the report!
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
` (8 preceding siblings ...)
2023-07-18 18:45 ` anlauf at gcc dot gnu.org
@ 2023-07-20 18:56 ` cvs-commit at gcc dot gnu.org
2023-07-20 19:06 ` cvs-commit at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-20 18:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:5279d2db0c4ace4f8d311d9c875d51a0fe7b40ea
commit r12-9782-g5279d2db0c4ace4f8d311d9c875d51a0fe7b40ea
Author: Harald Anlauf <anlauf@gmx.de>
Date: Sun Jul 16 22:17:27 2023 +0200
Fortran: intrinsics and deferred-length character arguments
[PR95947,PR110658]
gcc/fortran/ChangeLog:
PR fortran/95947
PR fortran/110658
* trans-expr.cc (gfc_conv_procedure_call): For intrinsic procedures
whose result characteristics depends on the first argument and
which
can be of type character, the character length will not be
deferred.
gcc/testsuite/ChangeLog:
PR fortran/95947
PR fortran/110658
* gfortran.dg/deferred_character_37.f90: New test.
(cherry picked from commit 95ddd2659849a904509067ec3a2770135149a722)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
` (9 preceding siblings ...)
2023-07-20 18:56 ` cvs-commit at gcc dot gnu.org
@ 2023-07-20 19:06 ` cvs-commit at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-20 19:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:7bd1373f87d581b1e5482f9c558d481c38027a99
commit r11-10918-g7bd1373f87d581b1e5482f9c558d481c38027a99
Author: Harald Anlauf <anlauf@gmx.de>
Date: Sun Jul 16 22:17:27 2023 +0200
Fortran: intrinsics and deferred-length character arguments
[PR95947,PR110658]
gcc/fortran/ChangeLog:
PR fortran/95947
PR fortran/110658
* trans-expr.c (gfc_conv_procedure_call): For intrinsic procedures
whose result characteristics depends on the first argument and
which
can be of type character, the character length will not be
deferred.
gcc/testsuite/ChangeLog:
PR fortran/95947
PR fortran/110658
* gfortran.dg/deferred_character_37.f90: New test.
(cherry picked from commit 95ddd2659849a904509067ec3a2770135149a722)
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-07-20 19:06 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-28 14:28 [Bug fortran/95947] New: PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used urbanjost at comcast dot net
2020-06-28 14:34 ` [Bug fortran/95947] " urbanjost at comcast dot net
2020-06-28 21:20 ` urbanjost at comcast dot net
2020-07-07 13:48 ` dominiq at lps dot ens.fr
2022-12-14 14:39 ` urbanjost at comcast dot net
2022-12-14 20:28 ` anlauf at gcc dot gnu.org
2022-12-14 20:54 ` anlauf at gcc dot gnu.org
2023-07-17 18:49 ` cvs-commit at gcc dot gnu.org
2023-07-18 18:40 ` cvs-commit at gcc dot gnu.org
2023-07-18 18:45 ` anlauf at gcc dot gnu.org
2023-07-20 18:56 ` cvs-commit at gcc dot gnu.org
2023-07-20 19:06 ` cvs-commit at gcc dot gnu.org
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).