public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/113885] New: ice in gimplify_expr, at gimplify.cc:18658
@ 2024-02-12 8:47 dcb314 at hotmail dot com
2024-02-12 19:38 ` [Bug fortran/113885] [13/14 Regression] ice in gimplify_expr, at gimplify.cc:18658 with finalization anlauf at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: dcb314 at hotmail dot com @ 2024-02-12 8:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113885
Bug ID: 113885
Summary: ice in gimplify_expr, at gimplify.cc:18658
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
Target Milestone: ---
Created attachment 57392
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57392&action=edit
F90 source code
The attached code, from the flang test suite, does this with recent gcc trunk:
test $ ~/gcc/results/bin/gfortran -c -w
./Lower/HLFIR/elemental-call-with-finalization.f90
./Lower/HLFIR/elemental-call-with-finalization.f90:27:13:
27 | x = elem(x)
| ^
internal compiler error: in gimplify_expr, at gimplify.cc:18658
xb99d5e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/home/dcb38/gcc/working/gcc/../../trunk.20210101/gcc/gimplify.cc:18658
0xb857bd gimplify_stmt(tree_node**, gimple**)
/home/dcb38/gcc/working/gcc/../../trunk.20210101/gcc/gimplify.cc:7480
0xb8fdd5 gimplify_modify_expr(tree_node**, gimple**, gimple**, bool)
/home/dcb38/gcc/working/gcc/../../trunk.20210101/gcc/gimplify.cc:6377
0xb8fdd5 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
The flang test suite is at:
https://github.com/llvm/llvm-project/tree/main/flang/test
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113885] [13/14 Regression] ice in gimplify_expr, at gimplify.cc:18658 with finalization
2024-02-12 8:47 [Bug fortran/113885] New: ice in gimplify_expr, at gimplify.cc:18658 dcb314 at hotmail dot com
@ 2024-02-12 19:38 ` anlauf at gcc dot gnu.org
2024-03-27 10:18 ` pault at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-02-12 19:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113885
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Target Milestone|--- |13.3
CC| |pault at gcc dot gnu.org
Priority|P3 |P4
Known to work| |11.4.1, 12.3.1
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=37336
Keywords| |ice-on-valid-code
Last reconfirmed| |2024-02-12
Summary|ice in gimplify_expr, at |[13/14 Regression] ice in
|gimplify.cc:18658 |gimplify_expr, at
| |gimplify.cc:18658 with
| |finalization
Status|UNCONFIRMED |NEW
Known to fail| |13.2.1, 14.0
--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed as a 13/14 regression.
Note that adding a component to type t, e.g., so that we have
type t
integer :: i
contains
final :: finalize
end type t
the ICE disappears.
Also note that the patch discussed in pr110987 does *not* help here.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113885] [13/14 Regression] ice in gimplify_expr, at gimplify.cc:18658 with finalization
2024-02-12 8:47 [Bug fortran/113885] New: ice in gimplify_expr, at gimplify.cc:18658 dcb314 at hotmail dot com
2024-02-12 19:38 ` [Bug fortran/113885] [13/14 Regression] ice in gimplify_expr, at gimplify.cc:18658 with finalization anlauf at gcc dot gnu.org
@ 2024-03-27 10:18 ` pault at gcc dot gnu.org
2024-03-29 7:23 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu.org @ 2024-03-27 10:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113885
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pault at gcc dot gnu.org
--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 57820
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57820&action=edit
Draft fix for this PR
Many thanks for the report.
The attachment needs some cleaning up and testing with other variants that
might generate the problem.
In fact, this is a double regression since the testcase below does not give the
right result for 'x' in the calls to test1 and test2.
The first regression is associated with the derived type having zero components
messing up the finalization calls. Strictly, this is not a regression since the
older versions of gfortran did not attempt the finalization.
The second regression is due to the attempt to place finalization calls in the
correct place relative to the evaluation of the rhs and the assignment to the
lhs. This is the cause of the incorrect results for the testcase below. I
believe that the correct output is:
after test1 x = 2 3
no. final calls = 4
after test2 x = 6 8
no. final calls = 12
nagfor agrees but ifort gives 3 and 8 respectively for the no. of
finalizations.
To my astonishment, given the current stage of the fix, it even regtests OK :-)
Paul
module types
type t
integer :: i
contains
final :: finalize
end type t
integer :: ctr = 0
contains
impure elemental subroutine finalize(x)
type(t), intent(inout) :: x
ctr = ctr + 1
end subroutine finalize
end module types
impure elemental function elem(x)
use types
type(t), intent(in) :: x
type(t) :: elem
elem%i = x%i + 1
end function elem
impure elemental function elem2(x, y)
use types
type(t), intent(in) :: x, y
type(t) :: elem2
elem2%i = x%i + y%i
end function elem2
subroutine test1(x)
use types
interface
impure elemental function elem(x)
use types
type(t), intent(in) :: x
type(t) :: elem
end function elem
end interface
type(t) :: x(:)
x = elem(x)
end subroutine test1
subroutine test2(x)
use types
interface
impure elemental function elem(x)
use types
type(t), intent(in) :: x
type(t) :: elem
end function elem
impure elemental function elem2(x, y)
use types
type(t), intent(in) :: x, y
type(t) :: elem2
end function elem2
end interface
type(t) :: x(:)
x = elem2(elem(x), elem(x))
end subroutine test2
program test113885
use types
interface
subroutine test1(x)
use types
type(t) :: x(:)
end subroutine
subroutine test2(x)
use types
type(t) :: x(:)
end subroutine
end interface
type(t) :: x(2) = [t(1),t(2)]
call test1 (x)
print "(a, 2i4)", "after test1 x = ", x
print "(a, i4)", "no. final calls = ", ctr
call test2 (x)
print "(a, 2i4)", "after test2 x = ", x
print "(a, i4)", "no. final calls = ",ctr
end
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113885] [13/14 Regression] ice in gimplify_expr, at gimplify.cc:18658 with finalization
2024-02-12 8:47 [Bug fortran/113885] New: ice in gimplify_expr, at gimplify.cc:18658 dcb314 at hotmail dot com
2024-02-12 19:38 ` [Bug fortran/113885] [13/14 Regression] ice in gimplify_expr, at gimplify.cc:18658 with finalization anlauf at gcc dot gnu.org
2024-03-27 10:18 ` pault at gcc dot gnu.org
@ 2024-03-29 7:23 ` cvs-commit at gcc dot gnu.org
2024-04-25 14:51 ` [Bug fortran/113885] [13 " pault at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-29 7:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113885
--- Comment #3 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:3c793f0361bc66d2a6bf0b3e1fb3234fc511e2a6
commit r14-9719-g3c793f0361bc66d2a6bf0b3e1fb3234fc511e2a6
Author: Paul Thomas <pault@gcc.gnu.org>
Date: Fri Mar 29 07:23:19 2024 +0000
Fortran: Fix a gimplifier ICE/wrong result with finalization [PR36337]
2024-03-29 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/36337
PR fortran/110987
PR fortran/113885
* trans-expr.cc (gfc_trans_assignment_1): Place finalization
block before rhs post block for elemental rhs.
* trans.cc (gfc_finalize_tree_expr): Check directly if a type
has no components, rather than the zero components attribute.
Treat elemental zero component expressions in the same way as
scalars.
gcc/testsuite/
PR fortran/113885
* gfortran.dg/finalize_54.f90: New test.
* gfortran.dg/finalize_55.f90: New test.
gcc/testsuite/
PR fortran/110987
* gfortran.dg/finalize_56.f90: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113885] [13 Regression] ice in gimplify_expr, at gimplify.cc:18658 with finalization
2024-02-12 8:47 [Bug fortran/113885] New: ice in gimplify_expr, at gimplify.cc:18658 dcb314 at hotmail dot com
` (2 preceding siblings ...)
2024-03-29 7:23 ` cvs-commit at gcc dot gnu.org
@ 2024-04-25 14:51 ` pault at gcc dot gnu.org
2024-05-06 9:47 ` cvs-commit at gcc dot gnu.org
2024-05-06 9:52 ` pault at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu.org @ 2024-04-25 14:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113885
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[13/14 Regression] ice in |[13 Regression] ice in
|gimplify_expr, at |gimplify_expr, at
|gimplify.cc:18658 with |gimplify.cc:18658 with
|finalization |finalization
--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
Updated summary
Paul
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113885] [13 Regression] ice in gimplify_expr, at gimplify.cc:18658 with finalization
2024-02-12 8:47 [Bug fortran/113885] New: ice in gimplify_expr, at gimplify.cc:18658 dcb314 at hotmail dot com
` (3 preceding siblings ...)
2024-04-25 14:51 ` [Bug fortran/113885] [13 " pault at gcc dot gnu.org
@ 2024-05-06 9:47 ` cvs-commit at gcc dot gnu.org
2024-05-06 9:52 ` pault at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-06 9:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113885
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Paul Thomas <pault@gcc.gnu.org>:
https://gcc.gnu.org/g:9f204cc695d27d0b8eb69d9a4d266261171185ae
commit r13-8690-g9f204cc695d27d0b8eb69d9a4d266261171185ae
Author: Paul Thomas <pault@gcc.gnu.org>
Date: Fri Mar 29 07:23:19 2024 +0000
Fortran: Fix a gimplifier ICE/wrong result with finalization [PR36337]
2024-03-29 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/36337
PR fortran/110987
PR fortran/113885
* trans-expr.cc (gfc_trans_assignment_1): Place finalization
block before rhs post block for elemental rhs.
* trans.cc (gfc_finalize_tree_expr): Check directly if a type
has no components, rather than the zero components attribute.
Treat elemental zero component expressions in the same way as
scalars.
gcc/testsuite/
PR fortran/113885
* gfortran.dg/finalize_54.f90: New test.
* gfortran.dg/finalize_55.f90: New test.
gcc/testsuite/
PR fortran/110987
* gfortran.dg/finalize_56.f90: New test.
(cherry picked from commit 3c793f0361bc66d2a6bf0b3e1fb3234fc511e2a6)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/113885] [13 Regression] ice in gimplify_expr, at gimplify.cc:18658 with finalization
2024-02-12 8:47 [Bug fortran/113885] New: ice in gimplify_expr, at gimplify.cc:18658 dcb314 at hotmail dot com
` (4 preceding siblings ...)
2024-05-06 9:47 ` cvs-commit at gcc dot gnu.org
@ 2024-05-06 9:52 ` pault at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu.org @ 2024-05-06 9:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113885
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> ---
Fixed on all affected branches. Thanks for the report.
Paul
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-05-06 9:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-12 8:47 [Bug fortran/113885] New: ice in gimplify_expr, at gimplify.cc:18658 dcb314 at hotmail dot com
2024-02-12 19:38 ` [Bug fortran/113885] [13/14 Regression] ice in gimplify_expr, at gimplify.cc:18658 with finalization anlauf at gcc dot gnu.org
2024-03-27 10:18 ` pault at gcc dot gnu.org
2024-03-29 7:23 ` cvs-commit at gcc dot gnu.org
2024-04-25 14:51 ` [Bug fortran/113885] [13 " pault at gcc dot gnu.org
2024-05-06 9:47 ` cvs-commit at gcc dot gnu.org
2024-05-06 9:52 ` 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).