This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/54603] New: Wrong code woth structure constructor for proc-pointer components
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 16 Sep 2012 19:58:50 +0000
- Subject: [Bug fortran/54603] New: Wrong code woth structure constructor for proc-pointer components
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54603
Bug #: 54603
Summary: Wrong code woth structure constructor for proc-pointer
components
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code, wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: janus@gcc.gnu.org, xarthisius.kk@gmail.com
Created attachment 28202
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28202
Test case
Reported by Kacper Kowalik via IRC.
Fortran 2003 (and 2008) allow to initialize procedure-pointer components via
the structure constructor, quoting F2003:
"R459 component-data-source is expr or data-target or proc-target"
And the latter can be per R742 and
"C726 A procedure-name shall be the name of ... or a procedure pointer"
I assume we either take a pointer reference too much or too little, leading to
both wrong code and an ICE, depending whether we pass the name of a procedure
or a procedure pointer.
For
this%a = ext_ptr(init, cleanup)
this%a%init => init
gfortran generates
ext_ptr.0.init = (void (*<T4b4>) (void)) init;
ext_ptr.0.cleanup = (void (*<T4b4>) (void)) cleanup;
this->_data->a = ext_ptr.0;
this->_data->a.init = *init;
Note the missing "*" in the failing declaration.
While using proc-pointers in the initialization
this%a = ext_ptr(this%a%init,this%a%cleanup)
gives an ICE in fold_convert_loc, bei fold-const.c:1880
The backtrace shows:
#0 fold_convert_loc (loc=0, type=0x2aaaac29f1f8, arg=<optimized out>) at
gcc/fold-const.c:1880
#1 0x000000000063406b in gfc_trans_scalar_assign
(lse=lse@entry=0x7fffffffcd70, rse=rse@entry=0x7fffffffcd20, ts=...,
l_is_temp=l_is_temp@entry=true,
deep_copy=deep_copy@entry=false, dealloc=dealloc@entry=true) at
/home/tobgcc/fortran/trans-expr.c:6427
#2 0x00000000006359b8 in gfc_trans_subcomponent_assign (expr=0x15e9210,
cm=0x15e37e0, dest=0x2aaaac27c0e0) at gcc/fortran/trans-expr.c:5588
#3 gfc_trans_structure_assign (dest=0x2aaaac295be0, expr=<error reading
variable: Unhandled dwarf expression opcode 0xfa>,
expr=<error reading variable: Unhandled dwarf expression opcode 0xfa>) at
gcc/fortran/trans-expr.c:5635