public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy
@ 2010-12-07 16:36 sfilippone at uniroma2 dot it
2010-12-07 17:00 ` [Bug fortran/46838] " burnus at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: sfilippone at uniroma2 dot it @ 2010-12-07 16:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46838
Summary: [OOP] Wrong allocation status for polymorphic
component INTENT(OUT) dummy
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: sfilippone@uniroma2.it
Created attachment 22672
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22672
test-case
Hello,
At r167487 the polymorphic component of an INTENT(OUT) dummy starts as
ALLOCATED, which is obviously wrong.
[sfilippo@localhost bug28]$ 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 --with-gmp=/home/travel/GCC/BUILDS/gmp
--with-mpfr=/home/travel/GCC/BUILDS/mpfr --with-mpc=/home/travel/GCC/BUILDS/mpc
: (reconfigured) ../gcc/configure --prefix=/usr/local/gnu46
--enable-languages=c,c++,fortran --with-gmp=/home/travel/GCC/BUILDS/gmp
--with-mpfr=/home/travel/GCC/BUILDS/mpfr --with-mpc=/home/travel/GCC/BUILDS/mpc
: (reconfigured) ../gcc/configure --prefix=/usr/local/gnu46
--with-gmp=/home/travel/GCC/BUILDS/gmp --with-mpfr=/home/travel/GCC/BUILDS/mpfr
--with-mpc=/home/travel/GCC/BUILDS/mpc --enable-languages=c,c++,fortran,lto
--no-create --no-recursion
Thread model: posix
gcc version 4.6.0 20101206 (experimental) (GCC)
[sfilippo@localhost bug28]$ gfortran -o bug28 bug28.f90
[sfilippo@localhost bug28]$ ./bug28
Generating Matrix (size=512)...
Allocated on an intent(OUT) var?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/46838] [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy
2010-12-07 16:36 [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy sfilippone at uniroma2 dot it
@ 2010-12-07 17:00 ` burnus at gcc dot gnu.org
2010-12-07 17:04 ` burnus at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-12-07 17:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46838
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-12-07 17:00:19 UTC ---
Work here as expected - but I get:
==32139== Conditional jump or move depends on uninitialised value(s)
==32139== at 0x400A36: cdall.1593 (oop.f90:139)
==32139== by 0x400CCE: create_matrix.1606 (oop.f90:117)
Line 139 is:
if (allocated(desc%indxmap)) then
>From the dump:
cdall (struct desc_type & restrict desc)
struct desc_type D.1561;
struct desc_type desc_type.0;
desc_type.0.matrix_data = 0B;
D.1561 = *desc;
*desc = desc_type.0;
D.1561.matrix_data = 0B;
D.1561.indxmap._data = 0B;
if (desc->indxmap._data != 0B)
The way one has to read it is as follows:
D.1561 = *desc; // Save pointers
*dest = desc_type.0; // Default initialize
// free allocatables via D.1561
The freeing works OK (except for a missing deep freeing, which is a different
PR). However, the initializing does not work. There is a line missing which
reads:
desc_type.0.indxmap._data = 0B;
The initialization happens via gfc_init_default_dt, which uses sym->value.
Hence, the problem might be in resolve.c.
* * *
Modified version: If one changes indxmap into an array, one gets:
oop.f90:21:0: internal compiler error: in gfc_conv_descriptor_data_get, at
fortran/trans-array.c:144
* * *
Reduced test case:
module descriptor_type
implicit none
type :: indx_map
end type indx_map
type desc_type
integer, allocatable :: matrix_data
class(indx_map), allocatable :: indxmap
end type desc_type
end module descriptor_type
program bug28
use descriptor_type
implicit none
type(desc_type) :: desc_a
call cdall(desc_a)
contains
subroutine cdall(desc)
type(desc_type), intent(out) :: desc
if (allocated(desc%indxmap)) stop 'ERROR'
STOP 'OK'
end subroutine cdall
end program bug28
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/46838] [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy
2010-12-07 16:36 [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy sfilippone at uniroma2 dot it
2010-12-07 17:00 ` [Bug fortran/46838] " burnus at gcc dot gnu.org
@ 2010-12-07 17:04 ` burnus at gcc dot gnu.org
2010-12-15 13:08 ` sfilippone at uniroma2 dot it
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-12-07 17:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46838
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-12-07 17:04:04 UTC ---
The default initializer is obtained via expr.c's gfc_default_initializer.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/46838] [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy
2010-12-07 16:36 [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy sfilippone at uniroma2 dot it
2010-12-07 17:00 ` [Bug fortran/46838] " burnus at gcc dot gnu.org
2010-12-07 17:04 ` burnus at gcc dot gnu.org
@ 2010-12-15 13:08 ` sfilippone at uniroma2 dot it
2010-12-28 10:52 ` [Bug fortran/46838] [OOP] Initialization of polymorphic allocatable components janus at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sfilippone at uniroma2 dot it @ 2010-12-15 13:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46838
--- Comment #3 from Salvatore Filippone <sfilippone at uniroma2 dot it> 2010-12-15 13:08:12 UTC ---
(In reply to comment #2)
> The default initializer is obtained via expr.c's gfc_default_initializer.
The original code gives
Overall matrix creation time : 1.69176E-01
[localhost:06639] Signal: Segmentation fault (11)
[localhost:06639] Signal code: (128)
[localhost:06639] Failing at address: (nil)
*** glibc detected *** ./ppde: munmap_chunk(): invalid pointer:
0x000000000064a8e6 ***
======= Backtrace: =========
/lib64/libc.so.6[0x39dc875676]
./ppde(__copy_psb_gen_block_map_mod_psb_gen_block_map_+0x143)[0x4c5f43]
./ppde(psb_cdcpy_+0x5c0)[0x4c11e0]
./ppde(psb_dcdbldext_+0x802)[0x4b3f92]
./ppde[0x419d26]
./ppde[0x41cbdd]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x39dc81ec5d]
./ppde[0x419339]
i.e. the problem surfaces in a SOURCE= allocation.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/46838] [OOP] Initialization of polymorphic allocatable components
2010-12-07 16:36 [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy sfilippone at uniroma2 dot it
` (2 preceding siblings ...)
2010-12-15 13:08 ` sfilippone at uniroma2 dot it
@ 2010-12-28 10:52 ` janus at gcc dot gnu.org
2010-12-28 12:51 ` janus at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2010-12-28 10:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46838
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2010.12.28 10:52:23
AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org
|gnu.org |
Summary|[OOP] Wrong allocation |[OOP] Initialization of
|status for polymorphic |polymorphic allocatable
|component INTENT(OUT) dummy |components
Ever Confirmed|0 |1
--- Comment #4 from janus at gcc dot gnu.org 2010-12-28 10:52:23 UTC ---
(In reply to comment #2)
> The default initializer is obtained via expr.c's gfc_default_initializer.
Indeed this is the place where things go wrong. Here's a patch:
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 168277)
+++ gcc/fortran/expr.c (working copy)
@@ -3648,7 +3648,8 @@ gfc_default_initializer (gfc_typespec *ts)
/* See if we have a default initializer in this, but not in nested
types (otherwise we could use gfc_has_default_initializer()). */
for (comp = ts->u.derived->components; comp; comp = comp->next)
- if (comp->initializer || comp->attr.allocatable)
+ if (comp->initializer || comp->attr.allocatable
+ || (comp->ts.type == BT_CLASS && CLASS_DATA (comp)->attr.allocatable))
break;
if (!comp)
@@ -3664,8 +3665,9 @@ gfc_default_initializer (gfc_typespec *ts)
if (comp->initializer)
ctor->expr = gfc_copy_expr (comp->initializer);
-
- if (comp->attr.allocatable)
+ else if (comp->attr.allocatable
+ || (comp->ts.type == BT_CLASS
+ && CLASS_DATA (comp)->attr.allocatable))
{
ctor->expr = gfc_get_expr ();
ctor->expr->expr_type = EXPR_NULL;
This fixes the test case in comment #1. However, I was not able to see a
failure with the test case in comment #0. Salvatore, can you check whether the
patch cures your troubles?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/46838] [OOP] Initialization of polymorphic allocatable components
2010-12-07 16:36 [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy sfilippone at uniroma2 dot it
` (3 preceding siblings ...)
2010-12-28 10:52 ` [Bug fortran/46838] [OOP] Initialization of polymorphic allocatable components janus at gcc dot gnu.org
@ 2010-12-28 12:51 ` janus at gcc dot gnu.org
2010-12-28 13:41 ` sfilippone at uniroma2 dot it
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2010-12-28 12:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46838
--- Comment #5 from janus at gcc dot gnu.org 2010-12-28 12:51:22 UTC ---
(In reply to comment #4)
> Here's a patch:
The patch in comment #4 had a few regressions (e.g. on alloc_comp_basics_1.f90
etc), but the following version regtests cleanly:
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 168293)
+++ gcc/fortran/expr.c (working copy)
@@ -3648,7 +3648,8 @@ gfc_default_initializer (gfc_typespec *ts)
/* See if we have a default initializer in this, but not in nested
types (otherwise we could use gfc_has_default_initializer()). */
for (comp = ts->u.derived->components; comp; comp = comp->next)
- if (comp->initializer || comp->attr.allocatable)
+ if (comp->initializer || comp->attr.allocatable
+ || (comp->ts.type == BT_CLASS && CLASS_DATA (comp)->attr.allocatable))
break;
if (!comp)
@@ -3665,7 +3666,8 @@ gfc_default_initializer (gfc_typespec *ts)
if (comp->initializer)
ctor->expr = gfc_copy_expr (comp->initializer);
- if (comp->attr.allocatable)
+ if (comp->attr.allocatable
+ || (comp->ts.type == BT_CLASS && CLASS_DATA (comp)->attr.allocatable))
{
ctor->expr = gfc_get_expr ();
ctor->expr->expr_type = EXPR_NULL;
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/46838] [OOP] Initialization of polymorphic allocatable components
2010-12-07 16:36 [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy sfilippone at uniroma2 dot it
` (4 preceding siblings ...)
2010-12-28 12:51 ` janus at gcc dot gnu.org
@ 2010-12-28 13:41 ` sfilippone at uniroma2 dot it
2010-12-29 16:14 ` janus at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sfilippone at uniroma2 dot it @ 2010-12-28 13:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46838
--- Comment #6 from Salvatore Filippone <sfilippone at uniroma2 dot it> 2010-12-28 13:40:52 UTC ---
(In reply to comment #5)
> (In reply to comment #4)
> > Here's a patch:
>
> The patch in comment #4 had a few regressions (e.g. on alloc_comp_basics_1.f90
> etc), but the following version regtests cleanly:
>
>
For me, it cures the reduced test case (bug28.f90) in comment #0, so it's
definitely a step in the right direction.
Unfortunately in the full application I still get this:
[localhost:15473] Signal: Segmentation fault (11)
[localhost:15473] Signal code: Address not mapped (1)
[localhost:15473] Failing at address: 0x13440000133b
[localhost:15472] [ 0] /lib64/libpthread.so.0(+0xf4a0) [0x7fae89b8b4a0]
[localhost:15472] [ 1] /lib64/libc.so.6(cfree+0x1c) [0x7fae898782dc]
[localhost:15472] [ 2]
./ppde(__copy_psb_gen_block_map_mod_psb_gen_block_map_+0x143) [0x4c45b3]
[localhost:15472] [ 3] ./ppde(psb_cdcpy_+0x700) [0x4bf850]
[localhost:15472] [ 4] ./ppde(psb_dcdbldext_+0x7e2) [0x4b2762]
[localhost:15472] [ 5] ./ppde() [0x41985f]
[localhost:15472] [ 6] ./ppde() [0x41c6dd]
[localhost:15472] [ 7] /lib64/libc.so.6(__libc_start_main+0xfd)
[0x7fae8981cc5d]
[localhost:15472] [ 8] ./ppde() [0x418ef9]
[localhost:15472] *** End of error message ***
I suppose this means that the original test case did not catch all there was;
I guess it would be best to declare this fixed and open a new one, as soon as I
have time to get a new reduced test case.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/46838] [OOP] Initialization of polymorphic allocatable components
2010-12-07 16:36 [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy sfilippone at uniroma2 dot it
` (5 preceding siblings ...)
2010-12-28 13:41 ` sfilippone at uniroma2 dot it
@ 2010-12-29 16:14 ` janus at gcc dot gnu.org
2010-12-29 16:31 ` janus at gcc dot gnu.org
2010-12-29 17:04 ` janus at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2010-12-29 16:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46838
--- Comment #7 from janus at gcc dot gnu.org 2010-12-29 16:14:20 UTC ---
Author: janus
Date: Wed Dec 29 16:14:11 2010
New Revision: 168322
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168322
Log:
2010-12-29 Janus Weil <janus@gcc.gnu.org>
PR fortran/46838
* expr.c (gfc_default_initializer): Handle allocatable CLASS components.
2010-12-29 Janus Weil <janus@gcc.gnu.org>
PR fortran/46838
* gfortran.dg/alloc_comp_class_2.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/alloc_comp_class_2.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/expr.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/46838] [OOP] Initialization of polymorphic allocatable components
2010-12-07 16:36 [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy sfilippone at uniroma2 dot it
` (6 preceding siblings ...)
2010-12-29 16:14 ` janus at gcc dot gnu.org
@ 2010-12-29 16:31 ` janus at gcc dot gnu.org
2010-12-29 17:04 ` janus at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2010-12-29 16:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46838
--- Comment #8 from janus at gcc dot gnu.org 2010-12-29 16:30:47 UTC ---
r168322 fixes the original test case as well as the reduction in comment #1.
ToDo: The array version (cf. comment #1) still ICEs:
implicit none
type indx_map
end type
type desc_type
class(indx_map), allocatable :: indxmap(:)
end type
type(desc_type) :: desc
if (allocated(desc%indxmap)) call abort()
end
internal compiler error: in gfc_conv_descriptor_data_get, at
fortran/trans-array.c:144
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/46838] [OOP] Initialization of polymorphic allocatable components
2010-12-07 16:36 [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy sfilippone at uniroma2 dot it
` (7 preceding siblings ...)
2010-12-29 16:31 ` janus at gcc dot gnu.org
@ 2010-12-29 17:04 ` janus at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2010-12-29 17:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46838
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #9 from janus at gcc dot gnu.org 2010-12-29 17:04:02 UTC ---
(In reply to comment #8)
> ToDo: The array version (cf. comment #1) still ICEs:
This is now being tracked by PR 43969, therefore I'm closing this one.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-12-29 17:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-07 16:36 [Bug fortran/46838] New: [OOP] Wrong allocation status for polymorphic component INTENT(OUT) dummy sfilippone at uniroma2 dot it
2010-12-07 17:00 ` [Bug fortran/46838] " burnus at gcc dot gnu.org
2010-12-07 17:04 ` burnus at gcc dot gnu.org
2010-12-15 13:08 ` sfilippone at uniroma2 dot it
2010-12-28 10:52 ` [Bug fortran/46838] [OOP] Initialization of polymorphic allocatable components janus at gcc dot gnu.org
2010-12-28 12:51 ` janus at gcc dot gnu.org
2010-12-28 13:41 ` sfilippone at uniroma2 dot it
2010-12-29 16:14 ` janus at gcc dot gnu.org
2010-12-29 16:31 ` janus at gcc dot gnu.org
2010-12-29 17:04 ` 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).