allocate on assignment problem
Tobias Burnus
burnus@net-b.de
Thu Sep 4 15:54:00 GMT 2008
Hi Macro, hello all,
marco restelli wrote:
> On Thu, Sep 4, 2008 at 9:15 AM, Daniel Kraft <d@domob.eu> wrote:
>
>> marco restelli wrote:
>>
>>> the attached code compiles with gfortran but produces segmentation
>>> fault at execution. Is this a gfortran problem in the allocation on
>>> assignment or is it me missing something?
>>>
>> I don't think allocation on assignment is implemented in gfortran, see
>> http://gcc.gnu.org/wiki/Fortran2003Status and thus you would try to write
>> into an unallocated array and cause the segfault. I'm not 100% sure about
>> this, however.
>>
It is half implemented. Reallocation on assignment is implemented for
derived types, but not for intrinsic types.
Hmm, I re-read the bug report,
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35810, and seemingly there
are additional issues: Not all reallocations seem work for derived
types; those with constructors do work.
For the time being, I would (re)allocate by hand. Also other compilers
such as ifort do not support reallocation with the default options
(ifort does support it with -assume realloc_lhs [the reason is that this
slows down all programs - and since only program did not use it]).
As GCC/gfortran is now in stage3 (only bug fixes), I think the support
will be deferred to GCC 4.5. The chances are very high that this feature
will be implemented in 4.5.
Tobias
More information about the Fortran
mailing list