[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947 --- Comment #11 from CVS Commits --- The releases/gcc-11 branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:7bd1373f87d581b1e5482f9c558d481c38027a99 commit r11-10918-g7bd1373f87d581b1e5482f9c558d481c38027a99 Author: Harald Anlauf 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)
[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947 --- Comment #10 from CVS Commits --- The releases/gcc-12 branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:5279d2db0c4ace4f8d311d9c875d51a0fe7b40ea commit r12-9782-g5279d2db0c4ace4f8d311d9c875d51a0fe7b40ea Author: Harald Anlauf 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)
[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
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!
[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947 --- Comment #8 from CVS Commits --- The releases/gcc-13 branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:ccf94ab2abb6969c04d51c7879f07edfbb97ae55 commit r13-7584-gccf94ab2abb6969c04d51c7879f07edfbb97ae55 Author: Harald Anlauf 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)
[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947 --- Comment #7 from CVS Commits --- The master branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:95ddd2659849a904509067ec3a2770135149a722 commit r14-2586-g95ddd2659849a904509067ec3a2770135149a722 Author: Harald Anlauf 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.
[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
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...
[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
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 (, 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 >; atmp.5.data = 0B; atmp.5.offset = 0; slen.4 = 0; _gfortran_pack_char (, , D.4314, D.4334, 0B, .n, 0); So we seem to clobber the string length before calling pack.
[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
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.
[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95947 Dominique d'Humieres changed: What|Removed |Added Last reconfirmed||2020-07-07 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #3 from Dominique d'Humieres --- Confirmed from at least GCC5.
[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
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
[Bug fortran/95947] PACK intrinsic returns blank strings when an allocatable character array with allocatable length is used
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=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 batcat batcat 10 4