https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102145
Bug ID: 102145 Summary: TKR mismatches with -pedantic: -fallow-argument-mismatch does not degrade errors to warnings Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: ripero84 at gmail dot com Target Milestone: --- In the presence of -pedantic, -fallow-argument-mismatch fails to degrade the mismatch errors to warnings: $ cat pedt.f90 MODULE M IMPLICIT NONE EXTERNAL :: X CONTAINS SUBROUTINE S(A) COMPLEX :: A(*) CALL X(A) END SUBROUTINE T(A) REAL :: A(*) CALL X(A) END END $ gfortran pedt.f90 -c -o pedt.o -fallow-argument-mismatch # Expected warning pedt.f90:8:11: 8 | CALL X(A) | 1 ...... 13 | CALL X(A) | 2 Warning: Type mismatch between actual argument at (1) and actual argument at (2) (COMPLEX(4)/REAL(4)). $ gfortran pedt.f90 -c -o pedt.o -fallow-argument-mismatch -pedantic # Unexpected error pedt.f90:8:11: 8 | CALL X(A) | 1 ...... 13 | CALL X(A) | 2 Error: Type mismatch between actual argument at (1) and actual argument at (2) (COMPLEX(4)/REAL(4)). This is: - undocumented; and - unexpected, since it effectively means that by adding -pedantic to a compilation line that already contains -fallow-argument-mismatch, mismatch warnings are upgraded to errors, despite -pedantic is only supposed to issue warnings. It seems that GCC developers have known for years that -pedantic may change warnings to errors in the absence of error-raising flags (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30929#c9), but it is still unclear to me whether this is undocumented or wrong behaviour. Note that there is evidence that -fallow-argument-mismatch is actually being processed: if the compiler finds multiple mismatches involving a given argument, it succeeds in only reporting one of them (as an error, not as the expected warning). I am seeking clarification about whether this is a bug (the combination of -pedantic -fallow-argument-mismatch flags should work differently / be forbidden), a documentation bug (in which case I would appreciate an explanation of the logic behind this, and an update to the documentation), or both, and I would be grateful for the fix(/es). I am aware that -fallow-argument-mismatch is a hack that should be avoided, but since users still need it, its behaviour and documentation should be at least consistent. Note that this issue has already been reported by some Fortran codes: https://github.com/cp2k/cp2k/issues/1019, https://gitlab.com/siesta-project/siesta/-/issues/130 . This seems to affect all versions of gfortran since GCC 10. It would be nice if any updates related to this were ported to the 10.x branch. Thank you for your help.