Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Gnu Fortran compiler crashes weirdly on simple Parameterized Derived Types example

109 views
Skip to first unread message

m...@szymki.net

unread,
Jan 29, 2021, 2:25:40 PM1/29/21
to
I wanted to give PDT a try, as I have never used them before, so I copied an example code form John Reid's paper on The New Features of Fortran 2003 (N1579), adding just 3 lines to let it test-run.
<code>
program test
TYPE matrix(kind,m,n)
INTEGER, KIND :: kind=KIND(0.0D0) ! gives a default value
INTEGER, LEN :: m,n ! no default value given
REAL(kind) :: element(m,n)
END TYPE matrix
TYPE (matrix(KIND(0.0),5,5)) :: a
a%element=0
print *, a
end program test
</code>

gfortran segfaults on this code, reporting
f951: internal compiler error: Segmentation fault.
This happens both with gcc 9.3.0 on Ubuntu and gcc 10.2.0 on Homebrew/MacOS Catalina.

I thought maybe PDT were not yet supported in GCC (though still the compiler should not crash) but after some experimenting I found that it DOES work fine (both compiling and then executing) if I either
a) remove the default initialization of 'kind' parameter, or
b) rename the parameter 'kind' to some other, less keywordly looking name, eg. 'kp'

So, apart from the weird crash of the compiler, I started to wonder whether the code in the example is valid. There are so many 'kind'-s in the first parameter definition that I really got *kinda* confused.

regards, Michal

FortranFan

unread,
Jan 29, 2021, 2:53:43 PM1/29/21
to
On Friday, January 29, 2021 at 2:25:40 PM UTC-5, m...@szymki.net wrote:

> .. the weird crash of the compiler, I started to wonder whether the code in the example is valid. There are so many 'kind'-s in the first parameter definition that I really got *kinda* confused.
> ..

@Michal,

Your code is valid. It's just that the PDT facility in GCC/gfortran is a limited implementation only and which itself has a *lot* of outstanding bug reports.

If you want to try PDTs in Fortran, I suggest you try Intel Fortran compiler i.e., the IFORT Classic in Intel oneAPI HPC toolkit which is now free for users:
https://software.intel.com/content/www/us/en/develop/tools/oneapi/hpc-toolkit/download.html

Also, for additional questions with PDTs, I suggest you use the Fortran Discourse site because it will be easier to include code snippets with Fortran *syntax highlighting*, to include images, attachments, etc. and to engage with a growing community that is using more and more modern tools for computing using Fortran:
https://fortran-lang.discourse.group/

0 new messages