public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43969] New: [OOP] CLASS(foo), ALLOCATABLE component bad initialization
@ 2010-05-03 10:11 sfilippone at uniroma2 dot it
2010-05-03 10:12 ` [Bug fortran/43969] " sfilippone at uniroma2 dot it
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: sfilippone at uniroma2 dot it @ 2010-05-03 10:11 UTC (permalink / raw)
To: gcc-bugs
Hello,
The attached code asserts that an ALLOCATABLE inner component starts its life
as ALLOCATED, which is contrary to everything I know about allocatables.
----------------------------- log -----------------------------------
[sfilippo@donald bug16]$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gnu46/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/usr/local/gnu46
--enable-languages=c,c++,fortran : (reconfigured) ../gcc/configure
--prefix=/usr/local/gnu46 --enable-languages=c,c++,fortran : (reconfigured)
../gcc/configure --prefix=/usr/local/gnu46 --enable-languages=c,c++,fortran :
(reconfigured) ../gcc/configure --prefix=/usr/local/gnu46
--enable-languages=c,c++,fortran,lto --no-create --no-recursion :
(reconfigured) ../gcc/configure --prefix=/usr/local/gnu46
--enable-languages=c,c++,fortran,lto --no-create --no-recursion :
(reconfigured) ../gcc/configure --prefix=/usr/local/gnu46
--enable-languages=c,c++,fortran,lto --no-create --no-recursion :
(reconfigured) ../gcc/configure --prefix=/usr/local/gnu46
--enable-languages=c,c++,fortran,lto --no-create --no-recursion
Thread model: posix
gcc version 4.6.0 20100430 (experimental) (GCC)
[sfilippo@donald bug16]$ gfortran -o testd16 testd16.f03
[sfilippo@donald bug16]$ ./testd16
Check on allocated: T
-----------------------------------------------------------------------------
Salvatore
--
Summary: [OOP] CLASS(foo), ALLOCATABLE component bad
initialization
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sfilippone at uniroma2 dot it
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43969
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/43969] [OOP] CLASS(foo), ALLOCATABLE component bad initialization
2010-05-03 10:11 [Bug fortran/43969] New: [OOP] CLASS(foo), ALLOCATABLE component bad initialization sfilippone at uniroma2 dot it
@ 2010-05-03 10:12 ` sfilippone at uniroma2 dot it
2010-05-03 10:37 ` sfilippone at uniroma2 dot it
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: sfilippone at uniroma2 dot it @ 2010-05-03 10:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from sfilippone at uniroma2 dot it 2010-05-03 10:12 -------
Created an attachment (id=20542)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20542&action=view)
test case
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43969
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/43969] [OOP] CLASS(foo), ALLOCATABLE component bad initialization
2010-05-03 10:11 [Bug fortran/43969] New: [OOP] CLASS(foo), ALLOCATABLE component bad initialization sfilippone at uniroma2 dot it
2010-05-03 10:12 ` [Bug fortran/43969] " sfilippone at uniroma2 dot it
@ 2010-05-03 10:37 ` sfilippone at uniroma2 dot it
2010-05-15 10:25 ` janus at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: sfilippone at uniroma2 dot it @ 2010-05-03 10:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from sfilippone at uniroma2 dot it 2010-05-03 10:37 -------
Created an attachment (id=20544)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20544&action=view)
Extended text case
With this and a fresh build at r158988 I get the following:
[sfilippo@donald bug16]$ ./testd16
Check on allocated: T
Check on allocated 3: T
At line 18 of file testd16.f03
Fortran runtime error: Attempting to allocate already allocated array 'try2'
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43969
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/43969] [OOP] CLASS(foo), ALLOCATABLE component bad initialization
2010-05-03 10:11 [Bug fortran/43969] New: [OOP] CLASS(foo), ALLOCATABLE component bad initialization sfilippone at uniroma2 dot it
2010-05-03 10:12 ` [Bug fortran/43969] " sfilippone at uniroma2 dot it
2010-05-03 10:37 ` sfilippone at uniroma2 dot it
@ 2010-05-15 10:25 ` janus at gcc dot gnu dot org
2010-05-15 10:47 ` [Bug fortran/43969] [OOP] ALLOCATABLE with polymorphic variables janus at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-05-15 10:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from janus at gcc dot gnu dot org 2010-05-15 10:25 -------
(In reply to comment #1)
> Created an attachment (id=20542)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20542&action=view) [edit]
Looking at the dump of this code shows:
The $data component of int is being set to zero (correctly):
try.int.$data = 0B;
However, the ALLOCATED statement is being evaluated to ".true":
static logical(kind=4) C.1566 = 1;
_gfortran_transfer_logical (&dt_parm.0, &C.1566, 4);
--
janus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2010-05-15 10:25:15
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43969
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/43969] [OOP] ALLOCATABLE with polymorphic variables
2010-05-03 10:11 [Bug fortran/43969] New: [OOP] CLASS(foo), ALLOCATABLE component bad initialization sfilippone at uniroma2 dot it
` (2 preceding siblings ...)
2010-05-15 10:25 ` janus at gcc dot gnu dot org
@ 2010-05-15 10:47 ` janus at gcc dot gnu dot org
2010-05-15 11:33 ` [Bug fortran/43969] [OOP] ALLOCATED() " sfilippone at uniroma2 dot it
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-05-15 10:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from janus at gcc dot gnu dot org 2010-05-15 10:46 -------
Turns out that fixing this one is completely trivial, once you actually have a
look at it :)
The ALLOCATED intrinsic was just not adjusted to handle CLASS variables yet.
The patch is as simple as this:
Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c (revision 159389)
+++ gcc/fortran/trans-intrinsic.c (working copy)
@@ -4529,6 +4529,8 @@ gfc_conv_allocated (gfc_se *se, gfc_expr *expr)
{
/* Allocatable scalar. */
arg1se.want_pointer = 1;
+ if (arg1->expr->ts.type == BT_CLASS)
+ gfc_add_component_ref (arg1->expr, "$data");
gfc_conv_expr (&arg1se, arg1->expr);
tmp = arg1se.expr;
}
Thanks for the bug report, Salvatore.
--
janus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |janus at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2010-05-15 10:25:15 |2010-05-15 10:46:53
date| |
Summary|[OOP] CLASS(foo), |[OOP] ALLOCATABLE with
|ALLOCATABLE component bad |polymorphic variables
|initialization |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43969
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/43969] [OOP] ALLOCATED() with polymorphic variables
2010-05-03 10:11 [Bug fortran/43969] New: [OOP] CLASS(foo), ALLOCATABLE component bad initialization sfilippone at uniroma2 dot it
` (3 preceding siblings ...)
2010-05-15 10:47 ` [Bug fortran/43969] [OOP] ALLOCATABLE with polymorphic variables janus at gcc dot gnu dot org
@ 2010-05-15 11:33 ` sfilippone at uniroma2 dot it
2010-05-15 13:53 ` janus at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: sfilippone at uniroma2 dot it @ 2010-05-15 11:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from sfilippone at uniroma2 dot it 2010-05-15 11:33 -------
(In reply to comment #4)
> Turns out that fixing this one is completely trivial, once you actually have a
> look at it :)
>
> The ALLOCATED intrinsic was just not adjusted to handle CLASS variables yet.
> The patch is as simple as this:
>
> Index: gcc/fortran/trans-intrinsic.c
> ===================================================================
> --- gcc/fortran/trans-intrinsic.c (revision 159389)
> +++ gcc/fortran/trans-intrinsic.c (working copy)
> @@ -4529,6 +4529,8 @@ gfc_conv_allocated (gfc_se *se, gfc_expr *expr)
> {
> /* Allocatable scalar. */
> arg1se.want_pointer = 1;
> + if (arg1->expr->ts.type == BT_CLASS)
> + gfc_add_component_ref (arg1->expr, "$data");
> gfc_conv_expr (&arg1se, arg1->expr);
> tmp = arg1se.expr;
> }
>
> Thanks for the bug report, Salvatore.
>
While we are at it, shouldn't the error message on ALLOCATE be changed to
reflect the fact that not only arrays but also scalars might be allocatables?
(see #2)
Salvatore
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43969
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/43969] [OOP] ALLOCATED() with polymorphic variables
2010-05-03 10:11 [Bug fortran/43969] New: [OOP] CLASS(foo), ALLOCATABLE component bad initialization sfilippone at uniroma2 dot it
` (4 preceding siblings ...)
2010-05-15 11:33 ` [Bug fortran/43969] [OOP] ALLOCATED() " sfilippone at uniroma2 dot it
@ 2010-05-15 13:53 ` janus at gcc dot gnu dot org
2010-05-15 14:18 ` [Bug fortran/43969] [OOP] ALLOCATED() with polymorphic arrays janus at gcc dot gnu dot org
2010-06-17 22:38 ` janus at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-05-15 13:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from janus at gcc dot gnu dot org 2010-05-15 13:52 -------
Subject: Bug 43969
Author: janus
Date: Sat May 15 13:52:33 2010
New Revision: 159431
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159431
Log:
2010-05-15 Janus Weil <janus@gcc.gnu.org>
PR fortran/43207
PR fortran/43969
* gfortran.h (gfc_class_null_initializer): New prototype.
* expr.c (gfc_class_null_initializer): New function to build a NULL
initializer for CLASS pointers.
* symbol.c (gfc_build_class_symbol): Modify internal naming of class
containers. Remove default NULL initialization of $data component.
* trans.c (gfc_allocate_array_with_status): Fix wording of an error
message.
* trans-expr.c (gfc_conv_initializer,gfc_trans_subcomponent_assign):
Use new function 'gfc_class_null_initializer'.
* trans-intrinsic.c (gfc_conv_allocated): Handle allocatable scalar
class variables.
2010-05-15 Janus Weil <janus@gcc.gnu.org>
PR fortran/43207
PR fortran/43969
* gfortran.dg/class_18.f03: New.
* gfortran.dg/class_19.f03: New.
Added:
trunk/gcc/testsuite/gfortran.dg/class_18.f03
trunk/gcc/testsuite/gfortran.dg/class_19.f03
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/expr.c
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/symbol.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/fortran/trans-intrinsic.c
trunk/gcc/fortran/trans.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43969
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/43969] [OOP] ALLOCATED() with polymorphic arrays
2010-05-03 10:11 [Bug fortran/43969] New: [OOP] CLASS(foo), ALLOCATABLE component bad initialization sfilippone at uniroma2 dot it
` (5 preceding siblings ...)
2010-05-15 13:53 ` janus at gcc dot gnu dot org
@ 2010-05-15 14:18 ` janus at gcc dot gnu dot org
2010-06-17 22:38 ` janus at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-05-15 14:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from janus at gcc dot gnu dot org 2010-05-15 14:18 -------
r159431 fixes the problems with allocatable scalar class variables in comment
#1 and #2, and also the wording of the error message reported in comment #5.
However, the ALLOCATED intrinsic still gives a gimplification error for
allocatable class arrays:
type foo
end type
class(foo), allocatable :: aca(:)
write(*,*) 'Check on allocated: ', allocated(aca)
end
--
janus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|wrong-code |ice-on-valid-code
Summary|[OOP] ALLOCATED() with |[OOP] ALLOCATED() with
|polymorphic variables |polymorphic arrays
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43969
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/43969] [OOP] ALLOCATED() with polymorphic arrays
2010-05-03 10:11 [Bug fortran/43969] New: [OOP] CLASS(foo), ALLOCATABLE component bad initialization sfilippone at uniroma2 dot it
` (6 preceding siblings ...)
2010-05-15 14:18 ` [Bug fortran/43969] [OOP] ALLOCATED() with polymorphic arrays janus at gcc dot gnu dot org
@ 2010-06-17 22:38 ` janus at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-06-17 22:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from janus at gcc dot gnu dot org 2010-06-17 22:38 -------
*** Bug 44570 has been marked as a duplicate of this bug. ***
--
janus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |boschmann at tp1 dot physik
| |dot uni-siegen dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43969
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-06-17 22:38 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-03 10:11 [Bug fortran/43969] New: [OOP] CLASS(foo), ALLOCATABLE component bad initialization sfilippone at uniroma2 dot it
2010-05-03 10:12 ` [Bug fortran/43969] " sfilippone at uniroma2 dot it
2010-05-03 10:37 ` sfilippone at uniroma2 dot it
2010-05-15 10:25 ` janus at gcc dot gnu dot org
2010-05-15 10:47 ` [Bug fortran/43969] [OOP] ALLOCATABLE with polymorphic variables janus at gcc dot gnu dot org
2010-05-15 11:33 ` [Bug fortran/43969] [OOP] ALLOCATED() " sfilippone at uniroma2 dot it
2010-05-15 13:53 ` janus at gcc dot gnu dot org
2010-05-15 14:18 ` [Bug fortran/43969] [OOP] ALLOCATED() with polymorphic arrays janus at gcc dot gnu dot org
2010-06-17 22:38 ` janus at gcc dot gnu dot 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).