From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 030E4385773F; Thu, 9 Nov 2023 14:03:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 030E4385773F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699538624; bh=a8ys8nccw1ZbKaC8gy317iHW3A0zf7piySk8N5ESTmo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Fqd2OBips37LCohaYiX/49z/T4OU0XkbpgEjbAE31l7aEUajA+T951thgYi9GvIvj K0/QmqwaQXDHsSBfAS3YDg7N9L1KbctL1n7AyQ5RK+hYarf6FxAi0xXgjVMEvR85ST 3JL/Q31cwfbZkw6E7HsxR1rrFfiOAOUGNvU0F7/A= From: "pault at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/112407] [13/14 Regression] Fix for PR37336 triggers an ICE in gfc_format_decoder while constructing a vtab Date: Thu, 09 Nov 2023 14:03:42 +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: 13.2.1 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pault at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: pault at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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=3D112407 --- Comment #6 from Paul Thomas --- (In reply to Tom=C3=A1=C5=A1 Trnka from comment #5) > I'm looking forward to any more information on the root cause. I have failed to produce a compact reproducer that resembles your bug. In f= act, you will note the first comment in the reproducer below, which is a bit iro= nic :-). You will note the commented out assignment and select type block. These generate the exact error. ie. Whenever 'new_t' appears in a variable expres= sion the error is triggered. I am deeply puzzled and will have another go at achieving some enlightenment tomorrow. Paul module m private new_t type s procedure(),pointer,nopass :: op end type type :: t integer :: i type (s) :: s contains procedure :: new_t procedure :: bar procedure :: add_t generic :: new =3D> new_t, bar generic, public :: assignment(=3D) =3D> add_t final :: final_t end type integer :: i =3D 0, finals =3D 0 contains ! recursive subroutine new_t (arg1, arg2) ! gfortran doesn't detect the recursion subroutine new_t (arg1, arg2) ! in 'new_t'! Other brands do. class(t), intent(out) :: arg1 type(t), intent(in) :: arg2 i =3D i + 1 ! arg1%s%op =3D> new_t ! This generates the error ! select type (arg1) ! As does this ! type is (t) ! arg1 =3D t(arg1%i,s(new_t)) ! end select print *, "new_t" if (i .ge. 10) return ! arg1 =3D arg2 ! gfortran does not detect the recursion if (arg1%i .ne. arg2%i) then ! According to F2018(8.5.10), arg1 should = be arg1%i =3D arg2%i ! undefined on invocation, unless any sub-components call arg1%new(arg2) ! are default initialised. gfortran sets arg1%i =3D 0 endif ! gfortran misses this recursion end subroutine bar(arg) class(t), intent(out) :: arg call arg%new(t(42, s(new_t))) end subroutine add_t (arg1, arg2) class(t), intent(out) :: arg1 type(t), intent(in) :: arg2 call arg1%new (arg2) end impure elemental subroutine final_t (arg1) type(t), intent(in) :: arg1 finals =3D finals + 1 end end use m class(t), allocatable :: x allocate(x) call x%new() ! gfortran ouputs 10*'new_t' print *, x%i, i, finals ! -||- 0 10 11 ! ! The other brands output 2*'new_t' + 42 2 3 end=