public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/64927] New: [4.7/4.8 Regression] Surprising error with -Wsurprising (-Wall) and TRANSFER + C_ASSOCIATED
@ 2015-02-03 20:01 anlauf at gmx dot de
  2015-02-03 20:17 ` [Bug fortran/64927] " anlauf at gmx dot de
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: anlauf at gmx dot de @ 2015-02-03 20:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64927

            Bug ID: 64927
           Summary: [4.7/4.8 Regression] Surprising error with
                    -Wsurprising (-Wall) and TRANSFER + C_ASSOCIATED
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gmx dot de

The following error occurs with 4.7 and 4.8, but not with 4.6 or 4.9.
The error is slightly annoying since -Wsurprising is automatically
enabled by -Wall, and it was a try-and-error by a colleague to trace
the problem to -Wsurprising.

The error shows up only if both indicated code lines with TRANSFER
and C_ASSOCIATED are active, commenting out any of them makes the
error disappear.  The dump-tree for 4.8 and 4.9 does not show
any difference if -Wno-surprising is set.  The error is bogus.

> cat gfcbug130.f90
! gfortran -c gfcbug130.f90 -Wall
! false error, compare -Wsurprising vs. -Wno-surprising

module surprise
  use iso_c_binding
  implicit none
  TYPE t_pointer
     TYPE(c_ptr) :: cptr
  END TYPE t_pointer
contains
  SUBROUTINE get_pointer (ibuf)
    INTEGER, INTENT(IN) :: ibuf(:)
    TYPE(t_pointer)     :: zp
! Error disappears if any line is commented out:
    zp = TRANSFER (ibuf, zp)
    IF (C_ASSOCIATED (zp% cptr)) Print *, "OK"
  END SUBROUTINE get_pointer
end module surprise

> gfc-48 -c gfcbug130.f90 -Wall       
gfcbug130.f90:16.22:

    IF (C_ASSOCIATED (zp% cptr)) Print *, "OK"
                      1
Error: Type mismatch in argument 'c_ptr_1' at (1); passed INTEGER(4) to
TYPE(c_ptr)

> gfc-48 -c gfcbug130.f90 -Wall -Wno-surprising

The problem does not occur in 4.9.  If there is an
easy fix for 4.8, could it be backported?

(I understand that the 4.7 branch is already closed.)

Thanks,
Harald


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

end of thread, other threads:[~2015-06-23  8:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-03 20:01 [Bug fortran/64927] New: [4.7/4.8 Regression] Surprising error with -Wsurprising (-Wall) and TRANSFER + C_ASSOCIATED anlauf at gmx dot de
2015-02-03 20:17 ` [Bug fortran/64927] " anlauf at gmx dot de
2015-02-03 21:49 ` kargl at gcc dot gnu.org
2015-02-03 21:59 ` sgk at troutmask dot apl.washington.edu
2015-02-09 14:26 ` [Bug fortran/64927] [4.8 " rguenth at gcc dot gnu.org
2015-02-11 14:43 ` dominiq at lps dot ens.fr
2015-02-11 19:31 ` anlauf at gmx dot de
2015-02-11 19:45 ` dominiq at lps dot ens.fr
2015-02-11 20:12 ` sgk at troutmask dot apl.washington.edu
2015-02-11 20:57 ` anlauf at gmx dot de
2015-02-13 14:53 ` dominiq at lps dot ens.fr
2015-02-13 21:24 ` anlauf at gmx dot de
2015-02-14 10:53 ` dominiq at lps dot ens.fr
2015-02-14 19:46 ` dominiq at lps dot ens.fr
2015-02-14 22:28 ` dominiq at lps dot ens.fr
2015-06-23  8:59 ` rguenth at gcc dot gnu.org

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).