public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/92065] [8/9/10/11 Regression] internal compiler error: in expand_expr_real_1
Date: Mon, 21 Dec 2020 10:09:02 +0000	[thread overview]
Message-ID: <bug-92065-4-yQPnCsWLza@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-92065-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92065

--- Comment #19 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems each function has properly its own this PARM_DECL, but the fun2 body
refers to the fun1 this PARM_DECL, which is invalid when fun2 is not nested in
fun1.

This wrong this PARM_DECL reference is added during:
#1  0x0000000001909a57 in build1 (code=INDIRECT_REF, type=<record_type
0x7fffea216498 __class_buggy_Foo_t>, node=<parm_decl 0x7fffea203700 this>)
    at ../../gcc/tree.c:4786
#2  0x0000000000ebcf48 in build1_loc (loc=91200, code=INDIRECT_REF,
type=<record_type 0x7fffea216498 __class_buggy_Foo_t>, 
    arg1=<parm_decl 0x7fffea203700 this>) at ../../gcc/tree.h:4382
#3  0x0000000000f01746 in build_fold_indirect_ref_loc (loc=91200, t=<parm_decl
0x7fffea203700 this>) at ../../gcc/fold-const.c:15930
#4  0x0000000000b6c166 in gfc_maybe_dereference_var (sym=0x38228a0,
var=<parm_decl 0x7fffea203700 this>, descriptor_only_p=false, 
    is_classarray=false) at ../../gcc/fortran/trans-expr.c:2787
#5  0x0000000000b6c97f in gfc_conv_variable (se=0x7fffffffd100, expr=0x37c0400)
at ../../gcc/fortran/trans-expr.c:2945
#6  0x0000000000b80aa3 in gfc_conv_expr (se=0x7fffffffd100, expr=0x37c0400) at
../../gcc/fortran/trans-expr.c:8864
#7  0x0000000000b80ba6 in gfc_conv_expr_val (se=0x7fffffffd100, expr=0x37c0400)
at ../../gcc/fortran/trans-expr.c:8909
#8  0x0000000000b80c55 in gfc_conv_expr_type (se=0x7fffffffd100,
expr=0x37c0400, type=<integer_type 0x7fffea056738 integer(kind=8)>)
    at ../../gcc/fortran/trans-expr.c:8923
#9  0x0000000000b2dceb in gfc_trans_dummy_array_bias (sym=0x3822be0,
tmpdesc=<var_decl 0x7ffff7fcae10 a.0>, block=0x7fffffffd430)
    at ../../gcc/fortran/trans-array.c:6753
#10 0x0000000000b57286 in gfc_trans_deferred_vars (proc_sym=0x3821ac0,
block=0x7fffffffd430) at ../../gcc/fortran/trans-decl.c:4829
#11 0x0000000000b5e212 in gfc_generate_function_code (ns=0x3825570) at
../../gcc/fortran/trans-decl.c:6984
#12 0x0000000000b19f9e in gfc_generate_module_code (ns=0x381c790) at
../../gcc/fortran/trans.c:2319
The proc_sym in the gfc_trans_deferred_vars above is fun2.

Already in gfc_trans_deferred_vars'
6638      as = IS_CLASS_ARRAY (sym) ? CLASS_DATA (sym)->as : sym->as;

the CLASS_DATA (sym)->as
contains:
(gdb) p debug_tree (as->upper[0]->symtree->n.sym->backend_decl)
 <parm_decl 0x7fffea203700 this
    type <reference_type 0x7fffea216690
        type <record_type 0x7fffea216498 __class_buggy_Foo_t type_4 TI
            size <integer_cst 0x7fffea041c00 constant 128>
            unit-size <integer_cst 0x7fffea041c18 constant 16>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea216498 fields <field_decl 0x7fffea215da8 _data> context <namespace_decl
0x7fffea2151c8 buggy>
            reference_to_this <reference_type 0x7fffea2165e8> chain <type_decl
0x7fffea215ed8 D.3955>>
        unsigned restrict DI
        size <integer_cst 0x7fffea041bb8 constant 64>
        unit-size <integer_cst 0x7fffea041bd0 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea216690>
    readonly unsigned DI passed-by-reference pr92605.f90:17:17 size
<integer_cst 0x7fffea041bb8 64> unit-size <integer_cst 0x7fffea041bd0 8>
    align:64 warn_if_not_align:0 context <function_decl 0x7fffea214700 fun1>
arg-type <reference_type 0x7fffea216690> chain <parm_decl 0x7fffea203780 a>>
i.e. the fun1's this PARM_DECL, even when this is during processing of fun2.

I don't know the class code in the fortran FE at all, but as has been said, one
can't just use PARM_DECLs of some other function except for nested functions,
so perhaps one need to use some magic sym that will translate to the this
parameter of the current method, or just detect uses of this symbol from other
method of the same class and replace it with the right one, whatever.

  parent reply	other threads:[~2020-12-21 10:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-92065-4@http.gcc.gnu.org/bugzilla/>
2020-04-20 20:08 ` [Bug fortran/92065] [8/9/10 " anlauf at gcc dot gnu.org
2020-12-19 22:22 ` [Bug fortran/92065] [8/9/10/11 " gtoth at umich dot edu
2020-12-19 23:17 ` kargl at gcc dot gnu.org
2020-12-19 23:35 ` gtoth at umich dot edu
2020-12-20  0:02 ` sgk at troutmask dot apl.washington.edu
2020-12-20  5:24 ` gtoth at umich dot edu
2020-12-20  7:07 ` sgk at troutmask dot apl.washington.edu
2020-12-20 12:14 ` dominiq at lps dot ens.fr
2020-12-20 13:55 ` tkoenig at gcc dot gnu.org
2020-12-20 17:39 ` gtoth at umich dot edu
2020-12-20 20:01 ` dominiq at lps dot ens.fr
2020-12-21  8:52 ` drikosev at gmail dot com
2020-12-21  9:40 ` jakub at gcc dot gnu.org
2020-12-21 10:09 ` jakub at gcc dot gnu.org [this message]
2020-12-21 10:12 ` dominiq at lps dot ens.fr
2020-12-21 10:13 ` jakub at gcc dot gnu.org
2020-12-22 21:15 ` drikosev at gmail dot com
2020-12-24 11:10 ` drikosev at gmail dot com
2020-12-26  1:04 ` drikosev at gmail dot com
2020-12-26  2:58 ` gtoth at umich dot edu
2021-05-14  9:52 ` [Bug fortran/92065] [9/10/11/12 " jakub at gcc dot gnu.org
2021-05-20 18:54 ` anlauf at gcc dot gnu.org
2021-05-21  6:59 ` rguenth at gcc dot gnu.org
2021-05-21  8:17 ` jakub at gcc dot gnu.org
2021-05-25 19:49 ` anlauf at gcc dot gnu.org
2021-06-01  8:15 ` rguenth at gcc dot gnu.org
2021-09-06 19:12 ` [Bug fortran/92065] [9/10/11 " anlauf at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-92065-4-yQPnCsWLza@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).