public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55825] New: [OOP] Bogus rank error with CLASS pointer assignment using structure constructors
@ 2012-12-28 17:08 burnus at gcc dot gnu.org
2012-12-28 17:37 ` [Bug fortran/55825] " janus at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-12-28 17:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55825
Bug #: 55825
Summary: [OOP] Bogus rank error with CLASS pointer assignment
using structure constructors
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: janus@gcc.gnu.org, pault@gcc.gnu.org
Created attachment 29058
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29058
Failing test case
Another test case by Reinhold Bader.
type :: t_ptr
class(interior), pointer :: r(:) => null()
end type t_ptr
...
type(interior), target :: r(3)
type(t_ptr) :: o1
...
o1 = t_ptr(r)
Gives:
o1 = t_ptr(r) ! fine, r has TARGET attribute and can't go away
1
Error: The rank of the element in the structure constructor at (1) does not
match that of the component (1/0)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/55825] [OOP] Bogus rank error with CLASS pointer assignment using structure constructors
2012-12-28 17:08 [Bug fortran/55825] New: [OOP] Bogus rank error with CLASS pointer assignment using structure constructors burnus at gcc dot gnu.org
@ 2012-12-28 17:37 ` janus at gcc dot gnu.org
2012-12-28 17:49 ` janus at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2012-12-28 17:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55825
--- Comment #1 from janus at gcc dot gnu.org 2012-12-28 17:36:39 UTC ---
Reduced test case:
program construct_poly
implicit none
type :: interior
real :: x
end type interior
type :: t_ptr
class(interior), pointer :: r(:) => null()
end type t_ptr
type(t_ptr) :: o1
type(interior), target :: r(3)
o1 = t_ptr(r)
end program
This gives me:
test.f90:16.13:
o1 = t_ptr(r)
1
Error: The rank of the element in the structure constructor at (1) does not
match that of the component (1/0)
test.f90:16.13:
o1 = t_ptr(r)
1
Error: Can't convert TYPE(interior) to CLASS(interior) at (1)
For the original test case, I get some more of these errors (on line 38, 52 and
63).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/55825] [OOP] Bogus rank error with CLASS pointer assignment using structure constructors
2012-12-28 17:08 [Bug fortran/55825] New: [OOP] Bogus rank error with CLASS pointer assignment using structure constructors burnus at gcc dot gnu.org
2012-12-28 17:37 ` [Bug fortran/55825] " janus at gcc dot gnu.org
@ 2012-12-28 17:49 ` janus at gcc dot gnu.org
2012-12-28 19:24 ` janus at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2012-12-28 17:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55825
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-12-28
Ever Confirmed|0 |1
--- Comment #2 from janus at gcc dot gnu.org 2012-12-28 17:49:41 UTC ---
Draft patch:
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 194743)
+++ gcc/fortran/resolve.c (working copy)
@@ -1089,7 +1089,10 @@ resolve_structure_cons (gfc_expr *expr, int init)
continue;
}
- rank = comp->as ? comp->as->rank : 0;
+ if (comp->ts.type == BT_CLASS)
+ rank = CLASS_DATA (comp)->as ? CLASS_DATA (comp)->as->rank : 0;
+ else
+ rank = comp->as ? comp->as->rank : 0;
if (cons->expr->expr_type != EXPR_NULL && rank != cons->expr->rank
&& (comp->attr.allocatable || cons->expr->rank))
{
This gets me past the first error in comment 1, but does not fix the second
one.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/55825] [OOP] Bogus rank error with CLASS pointer assignment using structure constructors
2012-12-28 17:08 [Bug fortran/55825] New: [OOP] Bogus rank error with CLASS pointer assignment using structure constructors burnus at gcc dot gnu.org
2012-12-28 17:37 ` [Bug fortran/55825] " janus at gcc dot gnu.org
2012-12-28 17:49 ` janus at gcc dot gnu.org
@ 2012-12-28 19:24 ` janus at gcc dot gnu.org
2012-12-28 20:19 ` janus at gcc dot gnu.org
2012-12-28 21:53 ` janus at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2012-12-28 19:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55825
--- Comment #3 from janus at gcc dot gnu.org 2012-12-28 19:23:38 UTC ---
The second error is fixed by the following:
Index: gcc/fortran/intrinsic.c
===================================================================
--- gcc/fortran/intrinsic.c (revision 194743)
+++ gcc/fortran/intrinsic.c (working copy)
@@ -4287,8 +4287,9 @@ gfc_convert_type_warn (gfc_expr *expr, gfc_typespe
if (expr->ts.type == BT_UNKNOWN)
goto bad;
- if (expr->ts.type == BT_DERIVED && ts->type == BT_DERIVED
- && gfc_compare_types (&expr->ts, ts))
+ if (expr->ts.type == BT_DERIVED
+ && (ts->type == BT_DERIVED || ts->type == BT_CLASS)
+ && gfc_compare_types (ts, &expr->ts))
return SUCCESS;
sym = find_conv (&expr->ts, ts);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/55825] [OOP] Bogus rank error with CLASS pointer assignment using structure constructors
2012-12-28 17:08 [Bug fortran/55825] New: [OOP] Bogus rank error with CLASS pointer assignment using structure constructors burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2012-12-28 19:24 ` janus at gcc dot gnu.org
@ 2012-12-28 20:19 ` janus at gcc dot gnu.org
2012-12-28 21:53 ` janus at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2012-12-28 20:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55825
--- Comment #4 from janus at gcc dot gnu.org 2012-12-28 20:19:06 UTC ---
After getting past the error messages with the patches in comment 2 and 3, the
test case segfaults with the following backtrace:
internal compiler error: Segmentation fault
o1 = t_ptr(r)
^
0xb0a58d crash_signal
/home/jweil/gcc48/trunk/gcc/toplev.c:334
0x63466e gfc_conv_scalarized_array_ref
/home/jweil/gcc48/trunk/gcc/fortran/trans-array.c:3042
0x634cd6 gfc_conv_array_ref(gfc_se*, gfc_array_ref*, gfc_symbol*, locus*)
/home/jweil/gcc48/trunk/gcc/fortran/trans-array.c:3168
0x661b9b gfc_conv_variable
/home/jweil/gcc48/trunk/gcc/fortran/trans-expr.c:1795
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/55825] [OOP] Bogus rank error with CLASS pointer assignment using structure constructors
2012-12-28 17:08 [Bug fortran/55825] New: [OOP] Bogus rank error with CLASS pointer assignment using structure constructors burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2012-12-28 20:19 ` janus at gcc dot gnu.org
@ 2012-12-28 21:53 ` janus at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2012-12-28 21:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55825
--- Comment #5 from janus at gcc dot gnu.org 2012-12-28 21:53:38 UTC ---
There are problems with handling CLASS components in
gfc_trans_subcomponent_assign:
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (revision 194743)
+++ gcc/fortran/trans-expr.c (working copy)
@@ -5934,11 +5934,14 @@ gfc_trans_subcomponent_assign (tree dest, gfc_comp
gfc_start_block (&block);
- if (cm->attr.pointer || cm->attr.proc_pointer)
+ if (cm->attr.pointer || cm->attr.proc_pointer
+ || (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.pointer))
{
gfc_init_se (&se, NULL);
/* Pointer component. */
- if (cm->attr.dimension && !cm->attr.proc_pointer)
+ if ((cm->attr.dimension
+ || (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.dimension))
+ && !cm->attr.proc_pointer)
{
/* Array pointer. */
if (expr->expr_type == EXPR_NULL)
However, this is not enough. The test case still gives an ICE.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-12-28 21:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-28 17:08 [Bug fortran/55825] New: [OOP] Bogus rank error with CLASS pointer assignment using structure constructors burnus at gcc dot gnu.org
2012-12-28 17:37 ` [Bug fortran/55825] " janus at gcc dot gnu.org
2012-12-28 17:49 ` janus at gcc dot gnu.org
2012-12-28 19:24 ` janus at gcc dot gnu.org
2012-12-28 20:19 ` janus at gcc dot gnu.org
2012-12-28 21:53 ` janus 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).