public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/114019] New: allocation with source of deferred character length entity
@ 2024-02-20 20:36 kargl at gcc dot gnu.org
2024-06-07 19:24 ` [Bug fortran/114019] " anlauf at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2024-02-20 20:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114019
Bug ID: 114019
Summary: allocation with source of deferred character length
entity
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: kargl at gcc dot gnu.org
Target Milestone: ---
Found this issues with the Fujitsu testsuite. The code
is reduced to the minimum required. If I had to guess,
gfc_charlen for source= is not set correctly.
!
! https://github.com/fujitsu/compiler-test-suite
! Reduced from Fortran/0069/0069_0037.f90
!
implicit none
character(:), pointer :: chr_pointer00
character(5), pointer :: chr_pointer01
character(1) :: w_character01 = "4"
allocate(chr_pointer00, source="123"//w_character01//"56")
allocate(chr_pointer01, source="123"//w_character01//"5")
print *,'pass'
end
% gfcx -c 0069/0069_0037.f90
0069/0069_0037.f90:9:60:
9 | allocate(chr_pointer00, source="123"//w_character01//"56")
| ^
Error: size of variable 'source.2' is too large
0069/0069_0037.f90:10:59:
10 | allocate(chr_pointer01, source="123"//w_character01//"5")
| ^
Error: size of variable 'source.5' is too large
during RTL pass: expand
0069/0069_0037.f90:9:60:
9 | allocate(chr_pointer00, source="123"//w_character01//"56")
| ^
internal compiler error: in lhd_incomplete_type_error, at langhooks.cc:208
0x77ff6f lhd_incomplete_type_error(unsigned int, tree_node const*, tree_node
const
../../gccx/gcc/langhooks.cc:208
0x13c00aa size_in_bytes_loc(unsigned int, tree_node const*)
../../gccx/gcc/tree.cc:3601
0x13c00aa size_in_bytes_loc(unsigned int, tree_node const*)
../../gccx/gcc/tree.cc:3589
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/114019] allocation with source of deferred character length entity
2024-02-20 20:36 [Bug fortran/114019] New: allocation with source of deferred character length entity kargl at gcc dot gnu.org
@ 2024-06-07 19:24 ` anlauf at gcc dot gnu.org
2024-06-27 20:08 ` anlauf at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-06-07 19:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114019
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2024-06-07
Keywords| |ice-on-valid-code
CC| |anlauf at gcc dot gnu.org
--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed. Reduced testcase:
subroutine s
character(1) :: w = "4"
character(:), pointer :: chr_pointer
allocate (chr_pointer, source= "123"//w ) ! ICE at -O0,-Og
! allocate (chr_pointer, source=adjustl("123"//w) ) ! ICE at -O0,-Og
! allocate (chr_pointer, source=trim ("123"//w) ) ! OK
! allocate (chr_pointer, source=repeat ("123"//w,1)) ! OK
end
In the indicated cases where we ICE at -O0 or -Og the length of source
is determined to be 4 at compile time, in the others it is an expression.
Setting a breakpoint in gfc_allocate_using_malloc:
(gdb) p debug_tree(size)
<integer_cst 0x7ffff6a29030 type <integer_type 0x7ffff6a25000 sizetype>
constant 4>
I do not see anything being obviously wrong with the dump-tree...
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/114019] allocation with source of deferred character length entity
2024-02-20 20:36 [Bug fortran/114019] New: allocation with source of deferred character length entity kargl at gcc dot gnu.org
2024-06-07 19:24 ` [Bug fortran/114019] " anlauf at gcc dot gnu.org
@ 2024-06-27 20:08 ` anlauf at gcc dot gnu.org
2024-06-28 20:02 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-06-27 20:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114019
--- Comment #2 from anlauf at gcc dot gnu.org ---
The following - seemingly hackish - change fixes the ICE:
diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index 93b633e212e..60275e18867 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -6464,7 +6464,10 @@ gfc_trans_allocate (gfc_code * code, gfc_omp_namelist
*omp_allocate)
else if (se.expr != NULL_TREE && temp_var_needed)
{
tree var, desc;
- tmp = GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (se.expr)) || is_coarray ?
+ tmp = (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (se.expr))
+ || is_coarray
+ || (code->expr3->ts.type == BT_CHARACTER
+ && code->expr3->rank == 0)) ?
se.expr
: build_fold_indirect_ref_loc (input_location, se.expr);
For reasons I do not see the case of source being a scalar character
expression, where we already have created se as a reference a few lines
further up in the code, is not handled by the original code.
This regtests cleanly.
Is there a better solution?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/114019] allocation with source of deferred character length entity
2024-02-20 20:36 [Bug fortran/114019] New: allocation with source of deferred character length entity kargl at gcc dot gnu.org
2024-06-07 19:24 ` [Bug fortran/114019] " anlauf at gcc dot gnu.org
2024-06-27 20:08 ` anlauf at gcc dot gnu.org
@ 2024-06-28 20:02 ` anlauf at gcc dot gnu.org
2024-06-29 12:58 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-06-28 20:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114019
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org
--- Comment #3 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2024-June/060609.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/114019] allocation with source of deferred character length entity
2024-02-20 20:36 [Bug fortran/114019] New: allocation with source of deferred character length entity kargl at gcc dot gnu.org
` (2 preceding siblings ...)
2024-06-28 20:02 ` anlauf at gcc dot gnu.org
@ 2024-06-29 12:58 ` cvs-commit at gcc dot gnu.org
2024-06-30 18:26 ` cvs-commit at gcc dot gnu.org
2024-06-30 18:37 ` anlauf at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-29 12:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114019
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:7682d115402743090f20aca63a3b5e6c205dedff
commit r15-1722-g7682d115402743090f20aca63a3b5e6c205dedff
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Jun 28 21:44:06 2024 +0200
Fortran: fix ALLOCATE with SOURCE of deferred character length [PR114019]
gcc/fortran/ChangeLog:
PR fortran/114019
* trans-stmt.cc (gfc_trans_allocate): Fix handling of case of
scalar character expression being used for SOURCE.
gcc/testsuite/ChangeLog:
PR fortran/114019
* gfortran.dg/allocate_with_source_33.f90: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/114019] allocation with source of deferred character length entity
2024-02-20 20:36 [Bug fortran/114019] New: allocation with source of deferred character length entity kargl at gcc dot gnu.org
` (3 preceding siblings ...)
2024-06-29 12:58 ` cvs-commit at gcc dot gnu.org
@ 2024-06-30 18:26 ` cvs-commit at gcc dot gnu.org
2024-06-30 18:37 ` anlauf at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-30 18:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114019
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:603b344c07aa55f8292446e8fd28f5da9a983a21
commit r14-10364-g603b344c07aa55f8292446e8fd28f5da9a983a21
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Jun 28 21:44:06 2024 +0200
Fortran: fix ALLOCATE with SOURCE of deferred character length [PR114019]
gcc/fortran/ChangeLog:
PR fortran/114019
* trans-stmt.cc (gfc_trans_allocate): Fix handling of case of
scalar character expression being used for SOURCE.
gcc/testsuite/ChangeLog:
PR fortran/114019
* gfortran.dg/allocate_with_source_33.f90: New test.
(cherry picked from commit 7682d115402743090f20aca63a3b5e6c205dedff)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/114019] allocation with source of deferred character length entity
2024-02-20 20:36 [Bug fortran/114019] New: allocation with source of deferred character length entity kargl at gcc dot gnu.org
` (4 preceding siblings ...)
2024-06-30 18:26 ` cvs-commit at gcc dot gnu.org
@ 2024-06-30 18:37 ` anlauf at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-06-30 18:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114019
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #6 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-15, and backported to 14-branch. Closing.
Might be backportable to 13-branch, but not tested.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-06-30 18:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-20 20:36 [Bug fortran/114019] New: allocation with source of deferred character length entity kargl at gcc dot gnu.org
2024-06-07 19:24 ` [Bug fortran/114019] " anlauf at gcc dot gnu.org
2024-06-27 20:08 ` anlauf at gcc dot gnu.org
2024-06-28 20:02 ` anlauf at gcc dot gnu.org
2024-06-29 12:58 ` cvs-commit at gcc dot gnu.org
2024-06-30 18:26 ` cvs-commit at gcc dot gnu.org
2024-06-30 18:37 ` anlauf 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).