public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/102145] New: TKR mismatches with -pedantic: -fallow-argument-mismatch does not degrade errors to warnings
@ 2021-08-31 14:59 ripero84 at gmail dot com
  2021-08-31 17:24 ` [Bug fortran/102145] " kargl at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: ripero84 at gmail dot com @ 2021-08-31 14:59 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-09-13  5:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 14:59 [Bug fortran/102145] New: TKR mismatches with -pedantic: -fallow-argument-mismatch does not degrade errors to warnings ripero84 at gmail dot com
2021-08-31 17:24 ` [Bug fortran/102145] " kargl at gcc dot gnu.org
2021-09-08 14:14 ` ripero84 at gmail dot com
2021-09-08 16:51 ` sgk at troutmask dot apl.washington.edu
2021-09-12 19:08 ` rimvydas.jas at gmail dot com
2021-09-12 19:09 ` rimvydas.jas at gmail dot com
2021-09-12 19:22 ` kargl at gcc dot gnu.org
2021-09-12 19:34 ` rimvydas.jas at gmail dot com
2021-09-12 22:56 ` sgk at troutmask dot apl.washington.edu
2021-09-12 23:40 ` rimvydas.jas at gmail dot com
2021-09-13  2:52 ` sgk at troutmask dot apl.washington.edu
2021-09-13  5:18 ` rimvydas.jas at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).