Hi, I am having a hard time understanding how to combine polymorphism and generic operators.
See below my attempt at implementing an abstract class Vect and its addition, then providing an implementation Vect2D.
The code compiles without warning using gcc 11.5, 13.2, 15.1, ifx 2025, and flang 21.1.0. It segfaults using gcc but runs fine with flang and ifc:
bbserv:VectClass $ make test1 FC=gfortran
bbserv:VectClass $ ./test1
v2D1 : 0.00000000 1.00000000
v2D2 : 3.00000000 4.00000000
v2D3 : 3.00000000 4.00000000
v2D1 + v2D2: not a Vect2D
In file 'test1.F90', around line 19: Error allocating 140721480245456 bytes: Cannot allocate memory
Error termination. Backtrace:
#0 0x7f5a044238a0 in ???
#
vs.
bbserv:VectClass $ make test1 FC=ifx
bbserv:VectClass $ ./test1
v2D1 : 0.0000000E+00 1.000000
v2D2 : 3.000000 4.000000
v2D3 : 3.000000 4.000000
v2D1 + v2D2: 3.000000 5.000000
v1 : 3.000000 5.000000
Is gfortran correct here? Am I missing something?
test1.F90 (487 Bytes)
m_VectClassAdd.F90 (1.6 KB)