public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/64958] Warn if INTENT(IN) is changed by passing to no-intent argument
2015-02-06 12:45 [Bug fortran/64958] New: Warn if INTENT(IN) is changed by passing to no-intent argument tkoenig at gcc dot gnu.org
@ 2015-02-06 12:45 ` tkoenig at gcc dot gnu.org
2015-02-06 13:08 ` tkoenig at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-02-06 12:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64958
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|unknown |5.0
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/64958] New: Warn if INTENT(IN) is changed by passing to no-intent argument
@ 2015-02-06 12:45 tkoenig at gcc dot gnu.org
2015-02-06 12:45 ` [Bug fortran/64958] " tkoenig at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-02-06 12:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64958
Bug ID: 64958
Summary: Warn if INTENT(IN) is changed by passing to no-intent
argument
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: tkoenig at gcc dot gnu.org
Consider the following code:
module foo
implicit none
contains
subroutine bar(n)
integer, intent(in) :: n
print *,"bar before dusty", n
call dusty(n)
print *,"bar after dusty", n
end subroutine bar
end module foo
program main
use foo
implicit none
integer :: n
n = 5
call bar(n)
end program main
subroutine dusty(n)
integer n
n = n - 1
end
What "dusty" does is illegal, but it may not be easy for the programmer
to catch this (especially if "dusty" is in a library).
So, it would be nice if -fcheck=all would contain a check which checked
if intent(in) dummy arguments are changed by being passed to
intent(none).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/64958] Warn if INTENT(IN) is changed by passing to no-intent argument
2015-02-06 12:45 [Bug fortran/64958] New: Warn if INTENT(IN) is changed by passing to no-intent argument tkoenig at gcc dot gnu.org
2015-02-06 12:45 ` [Bug fortran/64958] " tkoenig at gcc dot gnu.org
@ 2015-02-06 13:08 ` tkoenig at gcc dot gnu.org
2015-02-06 13:33 ` burnus at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-02-06 13:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64958
--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
If this mechanism is in place, it could also be used to catch code like
call foo(a+1)
...
subroutine foo(a)
a = a + 1
end subroutine
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/64958] Warn if INTENT(IN) is changed by passing to no-intent argument
2015-02-06 12:45 [Bug fortran/64958] New: Warn if INTENT(IN) is changed by passing to no-intent argument tkoenig at gcc dot gnu.org
2015-02-06 12:45 ` [Bug fortran/64958] " tkoenig at gcc dot gnu.org
2015-02-06 13:08 ` tkoenig at gcc dot gnu.org
@ 2015-02-06 13:33 ` burnus at gcc dot gnu.org
2015-02-06 14:04 ` tkoenig at gcc dot gnu.org
2015-03-06 13:52 ` dominiq at lps dot ens.fr
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2015-02-06 13:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64958
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
How is this supposed to work? I think in general, it is not that simple to test
for it. Or do you want to restrict it to scalar numeric intrinsic types - and
create a shadow variable? Even that might not work with optimization as we tell
the middle end that the variable doesn't change - and it might then in some
cases simply optimize the check away.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/64958] Warn if INTENT(IN) is changed by passing to no-intent argument
2015-02-06 12:45 [Bug fortran/64958] New: Warn if INTENT(IN) is changed by passing to no-intent argument tkoenig at gcc dot gnu.org
` (2 preceding siblings ...)
2015-02-06 13:33 ` burnus at gcc dot gnu.org
@ 2015-02-06 14:04 ` tkoenig at gcc dot gnu.org
2015-03-06 13:52 ` dominiq at lps dot ens.fr
4 siblings, 0 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-02-06 14:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64958
--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
If it is forbidden to modify an actual argument, we could make
a tempoary copy of that argument, pass that to a procedure where
it maches an intent(unknown) dummy argument, then do the comparison.
So, we would replace
subroutine bar(n)
integer, intent(in) :: n
call dusty(n)
end subroutine bar
with
subroutine bar(n)
integer, intent(in) :: n
integer :: shadow_n
shadow_n = n
call dusty(shadow_n)
if (n /= shadow_n) call _gfortran_runtime_error("bletchful")
end subroutine bar
where dusty has no explicit interface or the first dummy argument
of dusty has unknown intent.
It would probably make most sense for scalar intrinsic types inculding
character variables. Arrays of intrinsic types might also be a possibility,
but with decreasing return on investment, so to speak.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/64958] Warn if INTENT(IN) is changed by passing to no-intent argument
2015-02-06 12:45 [Bug fortran/64958] New: Warn if INTENT(IN) is changed by passing to no-intent argument tkoenig at gcc dot gnu.org
` (3 preceding siblings ...)
2015-02-06 14:04 ` tkoenig at gcc dot gnu.org
@ 2015-03-06 13:52 ` dominiq at lps dot ens.fr
4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-03-06 13:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64958
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-03-06
Ever confirmed|0 |1
--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-03-06 13:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-06 12:45 [Bug fortran/64958] New: Warn if INTENT(IN) is changed by passing to no-intent argument tkoenig at gcc dot gnu.org
2015-02-06 12:45 ` [Bug fortran/64958] " tkoenig at gcc dot gnu.org
2015-02-06 13:08 ` tkoenig at gcc dot gnu.org
2015-02-06 13:33 ` burnus at gcc dot gnu.org
2015-02-06 14:04 ` tkoenig at gcc dot gnu.org
2015-03-06 13:52 ` dominiq at lps dot ens.fr
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).