http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48786
Summary: [OOP] Generic ambiguity check too strict for polymorphic dummies Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org CC: ja...@gcc.gnu.org Created attachment 24110 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24110 Example program Reported at c.l.f by Arjen Markus http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/4a4e885f68b660bd I have not really thought about the issue, but I believe gfortran wrongly rejects the program. One has: type point2d with generic, public :: operator(+) => add_vector and type, extends(point2d) :: point3d with generic, public :: operator(+) => add_vector_3dversion As one can pass any "point3d" data type to either add_vector_3dversion or add_vector, gfortran complains: Error: 'add_vector_3d' and 'add_vector_2d' for GENERIC '+' at (1) are ambiguous However, the TKI is different, and thus I believe the error message is wrong - in calls, add_vector_3d should be preferred and only if not available, one should fall back to add_vector_2d. "A dummy argument is type, kind, and rank compatible, or TKR compatible, with another dummy argument if the first is type compatible with the second, the kind type parameters of the first have the same values as the corresponding kind type parameters of the second, and both have the same rank." (F2008, 12.4.3.4.5) -> I believe the arguments have a different (declared) type. It should also be somewhat compatible with: "12.5.5.2 Resolving procedure references to names established to be generic" - but there it does not tell which function one should call. Admittedly, I am a bit lost.