* [Bug fortran/103312] [9/10/11/12 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
@ 2021-11-19 10:54 ` marxin at gcc dot gnu.org
2021-11-19 17:15 ` kargl at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-19 10:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|ICE in gfc_find_component |[9/10/11/12 Regression] ICE
| |in gfc_find_component since
| |r9-1098-g3cf89a7b992d483e
Ever confirmed|0 |1
Last reconfirmed| |2021-11-19
Status|UNCONFIRMED |NEW
CC| |kargl at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r9-1098-g3cf89a7b992d483e.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/103312] [9/10/11/12 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
2021-11-19 10:54 ` [Bug fortran/103312] [9/10/11/12 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e marxin at gcc dot gnu.org
@ 2021-11-19 17:15 ` kargl at gcc dot gnu.org
2022-01-17 9:01 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2021-11-19 17:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|kargl at gcc dot gnu.org |
--- Comment #2 from kargl at gcc dot gnu.org ---
Not regression tested. Allows the code to compile.
I don't use CLASS, so have not idea if this is correct.
The code in gfc_find_component is set up for only TYPE,
UNION, and STRUCT. See the assert.
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 93118ad3455..997fa0d7848 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -1692,8 +1692,10 @@ generate_finalization_wrapper (gfc_symbol *derived,
gfc_namespace *ns,
final->attr.artificial = 1;
final->attr.always_explicit = 1;
final->attr.if_source = expr_null_wrapper ? IFSRC_IFBODY : IFSRC_DECL;
- if (ns->proc_name->attr.flavor == FL_MODULE)
+
+ if (ns->proc_name && ns->proc_name->attr.flavor == FL_MODULE)
final->module = ns->proc_name->name;
+
gfc_set_sym_referenced (final);
gfc_commit_symbol (final);
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index 8c9a1d00ce0..52d47b8b872 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -2492,6 +2492,8 @@ gfc_find_component (gfc_symbol *sym, const char *name,
if (sym->attr.flavor == FL_DERIVED)
sym = gfc_use_derived (sym);
+ else if (sym->ts.type == BT_DERIVED)
+ sym = gfc_use_derived (sym->ts.u.derived);
else
gcc_assert (gfc_fl_struct (sym->attr.flavor));
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/103312] [9/10/11/12 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
2021-11-19 10:54 ` [Bug fortran/103312] [9/10/11/12 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e marxin at gcc dot gnu.org
2021-11-19 17:15 ` kargl at gcc dot gnu.org
@ 2022-01-17 9:01 ` rguenth at gcc dot gnu.org
2022-05-27 9:46 ` [Bug fortran/103312] [10/11/12/13 " rguenth at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 9:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
Target Milestone|--- |9.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/103312] [10/11/12/13 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
` (2 preceding siblings ...)
2022-01-17 9:01 ` rguenth at gcc dot gnu.org
@ 2022-05-27 9:46 ` rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27 9:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|9.5 |10.4
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/103312] [10/11/12/13 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
` (3 preceding siblings ...)
2022-05-27 9:46 ` [Bug fortran/103312] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-07-07 10:41 ` [Bug fortran/103312] [11/12/13/14 " rguenth at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.4 |10.5
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/103312] [11/12/13/14 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
` (4 preceding siblings ...)
2022-06-28 10:46 ` jakub at gcc dot gnu.org
@ 2023-07-07 10:41 ` rguenth at gcc dot gnu.org
2024-04-17 7:10 ` pault at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.5 |11.5
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/103312] [11/12/13/14 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
` (5 preceding siblings ...)
2023-07-07 10:41 ` [Bug fortran/103312] [11/12/13/14 " rguenth at gcc dot gnu.org
@ 2024-04-17 7:10 ` pault at gcc dot gnu.org
2024-05-18 8:03 ` [Bug fortran/103312] [11/12/13/14/15 " pault at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2024-04-17 7:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pault at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |pault at gcc dot gnu.org
--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 57969
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57969&action=edit
Partial fix for the PR
The supplied testcase generates completely blank derived type symbols for the
_vptr component of 'this' in 'func'. The chunk in resolve.cc fixes that.
The rest of the patch allows the full testcase below to blast through to
translation, where it dies in trans-decl.cc - again with blanks symbols in the
default initializer this time.
Of the compilers to which I have access, only NAG succeeds with the full
testcase. If this%size() is replaced with a constant expression or an integer
dummy argument, all compilers succeed, including current versions of gfortran.
I have taken it but need to get on with daytime work for a few days.
Paul
module example
type, abstract :: foo
integer :: i
contains
procedure(foo_size), deferred :: size
procedure(foo_func), deferred :: func
end type
interface
function foo_func (this) result (string)
import :: foo
class(foo) :: this
character(this%size()) :: string
end function
pure integer function foo_size (this)
import foo
class(foo), intent(in) :: this
end function
end interface
end module
module extension
use example
implicit none
type, extends(foo) :: bar
! integer :: i
contains
procedure :: size
procedure :: func
end type
contains
pure integer function size (this)
class(bar), intent(in) :: this
size = this%i
end function
function func (this) result (string)
class(bar) :: this
character(this%size()) :: string
string = repeat ("x", len (string))
end function
end module
use example
use extension
type(bar) :: a
a%i = 5
print *, a%func()
end
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/103312] [11/12/13/14/15 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
` (6 preceding siblings ...)
2024-04-17 7:10 ` pault at gcc dot gnu.org
@ 2024-05-18 8:03 ` pault at gcc dot gnu.org
2024-05-18 8:05 ` pault at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2024-05-18 8:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 58231
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58231&action=edit
Preliminary fix for this PR
I went back to the beginning on this problem, having realised that it is far
too early to resolve the compcall of a class argument in gfc_reduce_init_expr.
Hence the chunk in expr.cc. The second chunk is (possibly) a bit of a kludge
and, I would have thought, should be checked, at very least by checking that
the class extends an abstract type. I will come back to this - yard duty calls!
A reduced test case, without the module 'example' and no type extension also
failed and is now fixed. Also failing in this reduced testcase was:
function func (this) result (string)
class(bar) :: this
character (:), allocatable :: string
allocate (character(this%size()) :: string)
string = repeat ("x", len (string))
end function
Again, this is fixed.
Finally, the patch even regression tests OK :-)
Enough for now.
Paul
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/103312] [11/12/13/14/15 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
` (7 preceding siblings ...)
2024-05-18 8:03 ` [Bug fortran/103312] [11/12/13/14/15 " pault at gcc dot gnu.org
@ 2024-05-18 8:05 ` pault at gcc dot gnu.org
2024-05-18 8:09 ` pault at gcc dot gnu.org
2024-05-23 7:00 ` cvs-commit at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2024-05-18 8:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gmx dot de
--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> ---
Hi Harald,
I put you in copy as a heads-up. I think that the patch of comment 7 will be
done and dusted by tomorrow night.
Regards
Paul
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/103312] [11/12/13/14/15 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
` (8 preceding siblings ...)
2024-05-18 8:05 ` pault at gcc dot gnu.org
@ 2024-05-18 8:09 ` pault at gcc dot gnu.org
2024-05-23 7:00 ` cvs-commit at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2024-05-18 8:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
--- Comment #9 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Paul Thomas from comment #7)
> Created attachment 58231 [details]
> Preliminary fix for this PR
>
> I went back to the beginning on this problem, having realised that it is far
> too early to resolve the compcall of a class argument in
> gfc_reduce_init_expr. Hence the chunk in expr.cc. The second chunk is
> (possibly) a bit of a kludge and, I would have thought, should be checked,
> at very least by checking that the class extends an abstract type. I will
> come back to this - yard duty calls!
>
> A reduced test case, without the module 'example' and no type extension also
> failed and is now fixed. Also failing in this reduced testcase was:
> function func (this) result (string)
> class(bar) :: this
> character (:), allocatable :: string
> allocate (character(this%size()) :: string)
> string = repeat ("x", len (string))
> end function
>
> Again, this is fixed.
>
> Finally, the patch even regression tests OK :-)
>
> Enough for now.
>
> Paul
I just noticed that the version on my tree has expr guarded in the additional
condition in gfc_reduce_init_expr. Otherwise gfortran.dg/pr103588.f90
segfaults.
Paul
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/103312] [11/12/13/14/15 Regression] ICE in gfc_find_component since r9-1098-g3cf89a7b992d483e
2021-11-18 11:40 [Bug fortran/103312] New: ICE in gfc_find_component asolokha at gmx dot com
` (9 preceding siblings ...)
2024-05-18 8:09 ` pault at gcc dot gnu.org
@ 2024-05-23 7:00 ` cvs-commit at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-23 7:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103312
--- Comment #10 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:2ce90517ed75c4af9fc0616f2670cf6dfcfa8a91
commit r15-788-g2ce90517ed75c4af9fc0616f2670cf6dfcfa8a91
Author: Paul Thomas <pault@gcc.gnu.org>
Date: Thu May 23 07:59:46 2024 +0100
Fortran: Fix ICEs due to comp calls in initialization exprs [PR103312]
2024-05-23 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/103312
* dependency.cc (gfc_dep_compare_expr): Handle component call
expressions. Return -2 as default and return 0 if compared with
a function expression that is from an interface body and has
the same name.
* expr.cc (gfc_reduce_init_expr): If the expression is a comp
call do not attempt to reduce, defer to resolution and return
false.
* trans-types.cc (gfc_get_dtype_rank_type,
gfc_get_nodesc_array_type): Fix whitespace.
gcc/testsuite/
PR fortran/103312
* gfortran.dg/pr103312.f90: New test.
^ permalink raw reply [flat|nested] 12+ messages in thread