public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/98534] New: Intrinsic functions failing with unlimited polymorphic actual arguments
@ 2021-01-05 15:11 pault at gcc dot gnu.org
2021-01-17 10:06 ` [Bug fortran/98534] " shmal_i at mail dot ru
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2021-01-05 15:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98534
Bug ID: 98534
Summary: Intrinsic functions failing with unlimited polymorphic
actual arguments
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
Assignee: pault at gcc dot gnu.org
Reporter: pault at gcc dot gnu.org
Target Milestone: ---
Created attachment 49891
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49891&action=edit
Provisional patch
Unlimited polymorphic actual arguments to 'storage_size' and 'transfer' fail,
when the dynamic type is character. This comes about because the '_len' field
is not used. The attached is a partial, provisional patch. I have not checked
other intrinsics yet.
It should also be noted that 'same_type_as' still uses the '_hash' field of the
vptr, rather than its address. This is known to fail in some cases.
A testcase can be found below.
Paul
! No errors with
character(*), parameter :: string = "abcdefgh"
class(*), allocatable :: star
character(len=:), allocatable :: chr
integer :: sz, sum1, sum2
! Part 1: works correctly
star = 1.0
sz = storage_size (star)/8
allocate (character(len=sz) :: chr)
chr = transfer (star, chr)
sum1 = sum ([(ichar(chr(i:i)), i = 1, sz)])
chr = transfer(1.0, chr)
sum2 = sum ([(ichar(chr(i:i)), i = 1, sz)])
if (sz /= kind (1.0)) stop 1
if (sum1 /= sum2) stop 2
deallocate (star) ! The automatic reallocation causes invalid writes
! and memory leaks. Even with this deallocation
! The invalid writes still occur.
deallocate (chr)
! Part 2: gets everything from because '_len' field of 'star' not used
star = string
sz = storage_size (star)/8
if (sz /= len (string)) print *, "stop 3" ! storage_size fails
sz = len (string) ! Ignore previous error in storage_size
allocate (character(len=sz) :: chr)
chr = transfer (star, chr)
sum1 = sum ([(ichar(chr(i:i)), i = 1, sz)])
chr = transfer(string, chr)
sum2 = sum ([(ichar(chr(i:i)), i = 1, sz)])
if (sum1 /= sum2) print *, "stop 4" ! transfer fails
deallocate (star, chr)
end
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/98534] Intrinsic functions failing with unlimited polymorphic actual arguments
2021-01-05 15:11 [Bug fortran/98534] New: Intrinsic functions failing with unlimited polymorphic actual arguments pault at gcc dot gnu.org
@ 2021-01-17 10:06 ` shmal_i at mail dot ru
2021-01-17 14:17 ` dominiq at lps dot ens.fr
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: shmal_i at mail dot ru @ 2021-01-17 10:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98534
Igor CHMAL <shmal_i at mail dot ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |shmal_i at mail dot ru
--- Comment #1 from Igor CHMAL <shmal_i at mail dot ru> ---
Created attachment 49984
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49984&action=edit
compiler
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/98534] Intrinsic functions failing with unlimited polymorphic actual arguments
2021-01-05 15:11 [Bug fortran/98534] New: Intrinsic functions failing with unlimited polymorphic actual arguments pault at gcc dot gnu.org
2021-01-17 10:06 ` [Bug fortran/98534] " shmal_i at mail dot ru
@ 2021-01-17 14:17 ` dominiq at lps dot ens.fr
2021-01-17 19:25 ` shmal_i at mail dot ru
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-01-17 14:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98534
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-01-17
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed from GCC9 up to GCC11. GCC8 vives
Undefined symbols for architecture x86_64:
"___copy_REAL_4_.3803", referenced from:
___vtab_REAL_4_.3802 in ccc5fkCP.o
"___copy_character_1.3889", referenced from:
___vtab_CHARACTER_1_.3888 in ccc5fkCP.o
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/98534] Intrinsic functions failing with unlimited polymorphic actual arguments
2021-01-05 15:11 [Bug fortran/98534] New: Intrinsic functions failing with unlimited polymorphic actual arguments pault at gcc dot gnu.org
2021-01-17 10:06 ` [Bug fortran/98534] " shmal_i at mail dot ru
2021-01-17 14:17 ` dominiq at lps dot ens.fr
@ 2021-01-17 19:25 ` shmal_i at mail dot ru
2021-04-17 10:21 ` pault at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: shmal_i at mail dot ru @ 2021-01-17 19:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98534
--- Comment #3 from Igor CHMAL <shmal_i at mail dot ru> ---
thanks’
>Воскресенье, 17 января 2021, 17:17 +03:00 от dominiq at lps dot ens.fr <gcc-bugzilla@gcc.gnu.org>:
>
>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98534
>
>Dominique d'Humieresерфтлыэ <dominiq at lps dot ens.fr> changed:
>
> What |Removed |Added
>----------------------------------------------------------------------------
> Last reconfirmed| |2021-01-17
> Status|UNCONFIRMED |NEW
> Ever confirmed|0 |1
>
>--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
>Confirmed from GCC9 up to GCC11. GCC8 vives
>
>Undefined symbols for architecture x86_64:
> "___copy_REAL_4_.3803", referenced from:
> ___vtab_REAL_4_.3802 in ccc5fkCP.o
> "___copy_character_1.3889", referenced from:
> ___vtab_CHARACTER_1_.3888 in ccc5fkCP.o
>
>--
>You are receiving this mail because:
>You are on the CC list for the bug.
С уважением,
Игорь ШМАЛЬ
e-mail: shmal_i@mail.ru
+7 (926) 376-76-02
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/98534] Intrinsic functions failing with unlimited polymorphic actual arguments
2021-01-05 15:11 [Bug fortran/98534] New: Intrinsic functions failing with unlimited polymorphic actual arguments pault at gcc dot gnu.org
` (2 preceding siblings ...)
2021-01-17 19:25 ` shmal_i at mail dot ru
@ 2021-04-17 10:21 ` pault at gcc dot gnu.org
2021-04-18 13:26 ` pault at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2021-04-17 10:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98534
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|pault at gcc dot gnu.org |unassigned at gcc dot gnu.org
CC| |burnus at gcc dot gnu.org
--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
This needs to be incorporated into the fix for PR100027. I hope that Jose takes
this PR over :-)
Paul
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/98534] Intrinsic functions failing with unlimited polymorphic actual arguments
2021-01-05 15:11 [Bug fortran/98534] New: Intrinsic functions failing with unlimited polymorphic actual arguments pault at gcc dot gnu.org
` (3 preceding siblings ...)
2021-04-17 10:21 ` pault at gcc dot gnu.org
@ 2021-04-18 13:26 ` pault at gcc dot gnu.org
2024-05-12 6:00 ` cvs-commit at gcc dot gnu.org
2024-05-12 6:07 ` pault at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2021-04-18 13:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98534
--- Comment #5 from Paul Thomas <pault at gcc dot gnu.org> ---
This needs to be incorporated into the fix for PR100027. I hope that Jose takes
this PR over :-)
Paul
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/98534] Intrinsic functions failing with unlimited polymorphic actual arguments
2021-01-05 15:11 [Bug fortran/98534] New: Intrinsic functions failing with unlimited polymorphic actual arguments pault at gcc dot gnu.org
` (4 preceding siblings ...)
2021-04-18 13:26 ` pault at gcc dot gnu.org
@ 2024-05-12 6:00 ` cvs-commit at gcc dot gnu.org
2024-05-12 6:07 ` pault at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-12 6:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98534
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Paul Thomas <pault@gcc.gnu.org>:
https://gcc.gnu.org/g:b9294757f82aae8de6d98c122cd4e3b98f685217
commit r15-386-gb9294757f82aae8de6d98c122cd4e3b98f685217
Author: Paul Thomas <pault@gcc.gnu.org>
Date: Sun May 12 06:59:45 2024 +0100
Fortran: Unlimited polymorphic intrinsic function arguments [PR84006]
2024-05-12 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/84006
PR fortran/100027
PR fortran/98534
* iresolve.cc (gfc_resolve_transfer): Emit a TODO error for
unlimited polymorphic mold.
* trans-expr.cc (gfc_resize_class_size_with_len): Use the fold
even if a block is not available in which to fix the result.
(trans_class_assignment): Enable correct assignment of
character expressions to unlimited polymorphic variables using
lhs _len field and rse string_length.
* trans-intrinsic.cc (gfc_conv_intrinsic_storage_size): Extract
the class expression so that the unlimited polymorphic class
expression can be used in gfc_resize_class_size_with_len to
obtain the storage size for character payloads. Guard the use
of GFC_DECL_SAVED_DESCRIPTOR by testing for DECL_LANG_SPECIFIC
to prevent the ICE. Also, invert the order to use the class
expression extracted from the argument.
(gfc_conv_intrinsic_transfer): In same way as 'storage_size',
use the _len field to obtaining the correct length for arg 1.
Add a branch for the element size in bytes of class expressions
with provision to make use of the unlimited polymorphic _len
field. Again, the class references are explicitly identified.
'mold_expr' was already declared. Use it instead of 'arg'. Do
not fix 'dest_word_len' for deferred character sources because
reallocation on assign makes use of it before it is assigned.
gcc/testsuite/
PR fortran/84006
PR fortran/100027
* gfortran.dg/storage_size_7.f90: New test.
PR fortran/98534
* gfortran.dg/transfer_class_4.f90: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/98534] Intrinsic functions failing with unlimited polymorphic actual arguments
2021-01-05 15:11 [Bug fortran/98534] New: Intrinsic functions failing with unlimited polymorphic actual arguments pault at gcc dot gnu.org
` (5 preceding siblings ...)
2024-05-12 6:00 ` cvs-commit at gcc dot gnu.org
@ 2024-05-12 6:07 ` pault at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2024-05-12 6:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98534
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> ---
Fixed on mainline.
Paul
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-05-12 6:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 15:11 [Bug fortran/98534] New: Intrinsic functions failing with unlimited polymorphic actual arguments pault at gcc dot gnu.org
2021-01-17 10:06 ` [Bug fortran/98534] " shmal_i at mail dot ru
2021-01-17 14:17 ` dominiq at lps dot ens.fr
2021-01-17 19:25 ` shmal_i at mail dot ru
2021-04-17 10:21 ` pault at gcc dot gnu.org
2021-04-18 13:26 ` pault at gcc dot gnu.org
2024-05-12 6:00 ` cvs-commit at gcc dot gnu.org
2024-05-12 6:07 ` pault 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).