public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/49436] Modifying actual arguments in subroutine not detected
Date: Thu, 16 Jun 2011 12:04:00 -0000	[thread overview]
Message-ID: <bug-49436-4-rc42JmQIQ6@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-49436-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49436

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-06-16 12:04:35 UTC ---
(In reply to comment #0)
> There's an aspect of the f95 standard that seems to not be enforced by
> gfortran.

The Fortran standard only requires that constraints ("C<number>" in the
standard) are checked by the compiler. Some other things might be checkable
(and compilers do diagnose some of those) - either at compile time or at run
time, but for a lot of code, it is practically impossible to diagnose the
invalidity.

Your program belongs to the latter:

call c(a)
[...]
subroutine c(n)
integer,intent(in)::n
a=15

This cannot be detected in general - and in specific cases only with
difficulty. I doubt that any Fortran compiler can detect this at compile time -
and I am not sure whether there is any which can do so at run time.

Assume, the variable "a" is in one file, the caller in another and the callee
in the third. In that case it should be clear that a compile-time diagnostic is
unfortunately not possible.

By the way, the result of your program depends on the compiler. Some might do a
copy-in of the argument, in that case "n" and "a" are disjunct. Or the compiler
might not do so - which gives the known result that modifying "a" also modifies
"n".


Thus, I think it is (unfortunately) a WONTFIX bug.


  parent reply	other threads:[~2011-06-16 12:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16 11:13 [Bug fortran/49436] New: " tjf at rsc dot anu.edu.au
2011-06-16 12:01 ` [Bug fortran/49436] " janus at gcc dot gnu.org
2011-06-16 12:04 ` burnus at gcc dot gnu.org [this message]
2011-06-16 16:34 ` kargl at gcc dot gnu.org

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-49436-4-rc42JmQIQ6@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).