public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "Joost.VandeVondele at mat dot ethz.ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/61180] New: surprising -Wsurprising warning
Date: Tue, 13 May 2014 16:36:00 -0000	[thread overview]
Message-ID: <bug-61180-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 61180
           Summary: surprising -Wsurprising warning
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Joost.VandeVondele at mat dot ethz.ch

To my surprise, -Wsurprising produces surprising warnings. The issue is the
following:

MODULE M1
 TYPE foo_type
   INTEGER, POINTER, DIMENSION(:) :: data
 END TYPE
CONTAINS
  FUNCTION get_data(foo) RESULT(res)
    TYPE(foo_type) :: foo
    INTEGER, POINTER, DIMENSION(:) :: res
    res=>foo%data
  END FUNCTION
END MODULE M1

  USE M1
  TYPE(foo_type) :: foo
  INTEGER, DIMENSION(:), ALLOCATABLE :: data1
  INTEGER, DIMENSION(:), POINTER :: data2
  INTEGER, DIMENSION(:), POINTER :: data3
  ALLOCATE(data1(10))
  ALLOCATE(data2(10))
  ALLOCATE(foo%data(10))
  ! no warning needed...pointer assignment not possible
  data1=get_data(foo)
  ! no warning needed...pointer assignment not intended 
  data2(:)=get_data(foo) 
  ! warning possible, but not documented on 
  ! gfortran/Error-and-Warning-Options.html#Error-and-Warning-Options
  data3=get_data(foo)
END PROGRAM

warnings for the first two cases are presumably not needed, the 3rd case is not
documented

bug.f90:22.8:

  data1=get_data(foo)
        1
Warning: POINTER-valued function appears on right-hand side of assignment at
(1)

The option has been added quite a while ago:

http://gcc.gnu.org/ml/fortran/2004-08/msg00220.html

maybe it should just be a bit restricted


             reply	other threads:[~2014-05-13 16:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 16:36 Joost.VandeVondele at mat dot ethz.ch [this message]
2014-05-13 17:39 ` [Bug fortran/61180] " dominiq at lps dot ens.fr
2014-05-13 17:46 ` Joost.VandeVondele at mat dot ethz.ch
2014-05-15 14:09 ` dominiq at lps dot ens.fr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-61180-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).