Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28988 Discussions

ICE with derived type with same member name as base type

Jauch
Beginner
681 Views

Hi,

I have a base type called TObject, a type that extends TObject called TCollection and a type that extends TCollection called TBlock.

In TObject i have a public field "character(len=:),allocatable :: Name"
In TBlock I set a procedure (function) also called Name (procedure::Name)

This causes an ICE when compiling. Changing the field or the procedure name to other thing solves the problem.

I attached a working project to exemplify the ICE. I am using Intel Fortran 15.0.1.148.

If that's the case, shouldn't the compiler warn that this is not possible?

Cheers,

Eduardo Jauch

0 Kudos
5 Replies
Steven_L_Intel1
Employee
681 Views

Thanks, we'll check it out.

0 Kudos
Steven_L_Intel1
Employee
681 Views

I have escalated the ICE as issue DPD200364909. However, the situation that triggers this is a violation of the language rules.

When TKeyword extends TObject, the standard says:

"An extended type includes all of the type parameters, all of the components, and the nonoverridden (4.5.7.3) type-bound procedures of its parent type. These are inherited by the extended type from the parent type." (4.5.7.2)

So Name is now an inherited component in TKeyword as if it had been declared there. Now we have a type-bound procedure also called Name. For this we have to look to 16.3.1, Classes of Local Identifiers, which lists four classes, including:

"(2) type parameters, components, and type-bound procedure bindings, in a separate class for each type,"

So the two entities called Name are both in the same class. (Don't be confused by the "separate class for each type", as these are in the same type.)

And lastly:

"Within its scope, a local identifier of one class shall not be the same as another local identifier of the same class,
except that a generic name may be the same as the name of a procedure as explained in 12.4.3.4 or the same as
the name of a derived type (4.5.10). A local identifier of one class may be the same as a local identifier of another
class."

The declaration violates the rule and hence is an error. The compiler should have given a useful message for this.

While working on this, I noticed that the compiler also gave a warning:

configuration.f90(3): warning #6738: The type/rank/keyword signature for this specific procedure matches another specific procedure that shares the same generic-name.   [INITIALIZEFILE]

I think this warning is bogus and will report that separately.

0 Kudos
Jauch
Beginner
681 Views

Hello Steve,

I imagined that the duplication of the name without being a procedure "override" should not be allowed. In fact, it was a mistake (I forgot about the field "Name" in the TObject. I should known better the rules, but I supposed that the "ICE" should not be happening.

Regarding the warning, as the code was working as expected, and I didn0t find anything wrong with the mentioned routine, I didn't pay too much attention to it.

Thanks and have a happy new year! :)

0 Kudos
Steven_L_Intel1
Employee
681 Views

You are absolutely correct that the ICE should not occur - that is always a compiler bug, no matter what triggered it. Thanks for reporting.

0 Kudos
Steven_L_Intel1
Employee
681 Views

In a future major release, the compiler will detect this error and give an appropriate diagnostic.

0 Kudos
Reply