From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2E71C3858D1E; Wed, 29 Nov 2023 10:35:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E71C3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701254110; bh=6on39T5otKXiHhxOSOPePoBErM1FTaTfTOGUUXVVhuE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZduQV8Ka/I84vn+cak+O7jPYOkazqajCTHrReEATpVi3AK2PW0kKIUIUg7UaVASJY HxUb7zEIKd67BEkuKb+Om3e8nnSkjq7HPC0zICmxFPsLSSn2H5tV5uITw70lvlqvwf NaBWOW+lBv7WW9QkelklyUqnCdpkbpA0SiRPaN58= From: "pault at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/102689] Segfault with RESHAPE of CLASS as actual argument Date: Wed, 29 Nov 2023 10:35:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pault at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102689 Paul Thomas 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 --- Confirmed! implicit none (type, external) type t integer :: i end type t integer :: j integer :: src(100) =3D [(j, j=3D1,100)] class(t), allocatable :: B(:,:,:), D(:) allocate(t :: B(10,10,1)) B(:,:,:)%i =3D RESHAPE(src, shape(B)) D =3D reshape(B, [100]) call class_bar(D) contains subroutine class_bar(x) class(t), intent(in) :: x(:) integer :: k if (any (x(:)%i /=3D [(k, k=3D1,100)])) error stop 1 end end Works as intended. Inspection of the original code reveals: atmp.19.dtype =3D {.elem_len=3D4, .rank=3D1, .type=3D5}; atmp.19.dim[0].stride =3D 1; atmp.19.dim[0].lbound =3D 0; atmp.19.dim[0].ubound =3D 99; atmp.19.span =3D 4; atmp.19.data =3D (void * restrict) &A.20; atmp.19.offset =3D 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=