Doubt w.r.t. to gfortran's interpretation of the Fortran2003 standard
"Alberto F. Martín Huertas"
amartin@cimne.upc.edu
Fri Oct 31 10:00:00 GMT 2014
If I comment out the second generic, the output 'sum_madres' is ALSO
produced by the Intel compiler
However, the IBM compiler outputs 'sum_hijos".
If I do NOT comment out the second generic, the Intel and IBM
can compile the code, and the expression produces 'sum_hijos", while
the gfortran compiler does not compile the code.
So, my question now is, assuming that the second generic is NOT LEGAL
(according to Metcalf, Reid and Cohen and F2003 handbook), should
the expression
hres => h1 + m1 ! with h1 being type(hijo)
output 'sum_madres' or 'sum_hijos' ?
Best regards,
Alberto.
On 31/10/14 10:44, Salvatore Filippone wrote:
> YOu are correct, that is the behaviour I get from current trunk.
> Both Metcalf, Reid and Cohen and F2003 handbook concur that you do not
> need the second generic statement.
> From your mail I do not see whether the output 'sum_madres' is
> produced by the Intel compiler when you comment the second generic (it
> definitely works this way with gfortran); is this the case?
> If they behave differently, then one of them is wrong.
>
> Salvatore
>
> On Fri, Oct 31, 2014 at 10:27 AM, "Alberto F. MartÃn Huertas"
> <amartin@cimne.upc.edu> wrote:
>> Dear Salvatore,
>>
>> thanks for your answer. If "all TBPs that override it are accesible
>> through the same generic interface" and "overriding the + generic
>> interface is not needed", why does an expression like this
>>
>> hres => h1 + m1 ! with h1 being type(hijo)
>>
>> outputs 'sum_madres' instead of 'sum_hijos'.
>>
>> Best regards,
>> Alberto.
>>
>>
>>
>> On 31/10/14 10:15, Salvatore Filippone wrote:
>>> Alberto F. MartÃn Huertas wrote:
>>>
>>>> Dear Fortran@gcc.gnu.org members,
>>>>
>>>> I would like to know if the following Fortran2003 code snippet is
>>>> compliant or not
>>>>
>>>> with the Fortran2003 standard:
>>>>
>>>> module overwrite
>>> > type madre
>>> > contains
>>> > procedure :: sum => sum_madres
>>> > generic :: operator(+) => sum
>>> > end type madre
>>>> type, extends(madre) :: hijo
>>>> contains
>>>> procedure :: sum => sum_hijos_compliant
>>>> generic :: operator(+) => sum
>>>> end type hijo
>>> Your code is wrong (I've been through the same error a long time ago :)
>>> The fix is: do NOT add the derived procedure to the generic. Once a
>>> type-bound procedure is added to a GENERIC interface, all TBPs that
>>> override it are accessible through the same generic. In other words,
>>> you only need to comment out the second generic statement as in the
>>> following:
>>> module overwrite
>>> type madre
>>> contains
>>> procedure :: sum => sum_madres
>>> generic :: operator(+) => sum
>>> end type madre
>>>
>>> type, extends(madre) :: hijo
>>> contains
>>> procedure :: sum => sum_hijos_compliant
>>> ! generic :: operator(+) => sum ! not needed.
>>> end type hijo
>>>
>>> Hope this helps
>>> Salvatore Filippone
>>
>> --
>> Alberto F. MartÃn-Huertas
>> Centre Internacional de Mètodes Numèrics a l'Enginyeria (CIMNE)
>> Parc Mediterrani de la Tecnologia, UPC
>> Esteve Terradas 5, Building C3, Office 215,
>> 08860 Castelldefels (Barcelona, Spain)
>> Tel.: (+34) 9341 34223
>> e-mail: amartin@cimne.upc.edu
>>
>> ________________
>> IMPORTANT NOTICE
>> All personal data contained on this mail will be processed confidentially
>> and registered in a file property of CIMNE in
>> order to manage corporate communications. You may exercise the rights of
>> access, rectification, erasure and object by
>> letter sent to Ed. C1 Campus Norte UPC. Gran Capitán s/n Barcelona.
>>
--
Alberto F. MartÃn-Huertas
Centre Internacional de Mètodes Numèrics a l'Enginyeria (CIMNE)
Parc Mediterrani de la Tecnologia, UPC
Esteve Terradas 5, Building C3, Office 215,
08860 Castelldefels (Barcelona, Spain)
Tel.: (+34) 9341 34223
e-mail: amartin@cimne.upc.edu
________________
IMPORTANT NOTICE
All personal data contained on this mail will be processed confidentially and registered in a file property of CIMNE in
order to manage corporate communications. You may exercise the rights of access, rectification, erasure and object by
letter sent to Ed. C1 Campus Norte UPC. Gran Capitán s/n Barcelona.
More information about the Fortran
mailing list