public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug fortran/102689] New: Segfault with RESHAPE of CLASS as actual argument @ 2021-10-11 20:00 burnus at gcc dot gnu.org 2023-11-29 10:35 ` [Bug fortran/102689] " pault at gcc dot gnu.org 2023-11-30 14:15 ` pault at gcc dot gnu.org 0 siblings, 2 replies; 3+ messages in thread From: burnus at gcc dot gnu.org @ 2021-10-11 20:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102689 Bug ID: 102689 Summary: Segfault with RESHAPE of CLASS as actual argument Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Target Milestone: --- Created attachment 51586 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51586&action=edit testcase - compile & run (fails with segfault at marked line) Dummy and actual argument are CLASS, then: call class_bar (RESHAPE (B, [100])) will segfault at runtime. Besides the actual crash, the question is why there is a call to the library at all: _gfortran_reshape_4 (&atmp.25, D.4357, D.4383, 0B, 0B); At least for most common cases, it looks as if this should be inlined. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/102689] Segfault with RESHAPE of CLASS as actual argument 2021-10-11 20:00 [Bug fortran/102689] New: Segfault with RESHAPE of CLASS as actual argument burnus at gcc dot gnu.org @ 2023-11-29 10:35 ` pault at gcc dot gnu.org 2023-11-30 14:15 ` pault at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: pault at gcc dot gnu.org @ 2023-11-29 10:35 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102689 Paul Thomas <pault at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2023-11-29 CC| |pault at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Paul Thomas <pault at gcc dot gnu.org> --- Confirmed! implicit none (type, external) type t integer :: i end type t integer :: j integer :: src(100) = [(j, j=1,100)] class(t), allocatable :: B(:,:,:), D(:) allocate(t :: B(10,10,1)) B(:,:,:)%i = RESHAPE(src, shape(B)) D = reshape(B, [100]) call class_bar(D) contains subroutine class_bar(x) class(t), intent(in) :: x(:) integer :: k if (any (x(:)%i /= [(k, k=1,100)])) error stop 1 end end Works as intended. Inspection of the original code reveals: atmp.19.dtype = {.elem_len=4, .rank=1, .type=5}; atmp.19.dim[0].stride = 1; atmp.19.dim[0].lbound = 0; atmp.19.dim[0].ubound = 99; atmp.19.span = 4; atmp.19.data = (void * restrict) &A.20; atmp.19.offset = 0; _gfortran_reshape (&atmp.19, D.4442, D.4451, 0B, 0B); class_bar (atmp.19); ie. The class formal argument is being fed an array descriptor. This is a problem with gfc_conv_procedure_call. The discussion about inlining or not is for another day :-) Thanks for the report, Tobias. Paul ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/102689] Segfault with RESHAPE of CLASS as actual argument 2021-10-11 20:00 [Bug fortran/102689] New: Segfault with RESHAPE of CLASS as actual argument burnus at gcc dot gnu.org 2023-11-29 10:35 ` [Bug fortran/102689] " pault at gcc dot gnu.org @ 2023-11-30 14:15 ` pault at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: pault at gcc dot gnu.org @ 2023-11-30 14:15 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102689 --- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> --- Created attachment 56730 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56730&action=edit Another failing testcase With the attached, we should get: [pault@pc30 pr87477]$ rm ./a.out;ifort ~/prs/pr102689/pr1*.f90 ;./a.out type is 's' at line 0 type is 's' at line 2 type is 's' at line 3 type is 's' at line 4 type is 's' at line 5 whereas gfortran gives type is 's' at line 0 type is 't' at line 2 line 2 1275 should be 5050 type is 't' at line 3 line 3 1275 should be 5050 type is 't' at line 4 line 4 1275 should be 5050 type is 't' at line 5 line 5 1275 should be 5050 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-30 14:15 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-10-11 20:00 [Bug fortran/102689] New: Segfault with RESHAPE of CLASS as actual argument burnus at gcc dot gnu.org 2023-11-29 10:35 ` [Bug fortran/102689] " pault at gcc dot gnu.org 2023-11-30 14:15 ` 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).