public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set
@ 2006-06-12 20:18 tobias dot burnus at physik dot fu-berlin dot de
2006-06-13 19:48 ` [Bug fortran/28004] " pault at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 12+ messages in thread
From: tobias dot burnus at physik dot fu-berlin dot de @ 2006-06-12 20:18 UTC (permalink / raw)
To: gcc-bugs
GNU Fortran 95 (GCC) 4.2.0 20060612.
If I write a program with a intent(out) variable and this varibale is not set,
gfortran only writes:
warning: unused variable C
Expected: Default warning like ifort/NAG f95/g95:
In file ff.f90:7
subroutine sub(a)
1
Warning (158): INTENT(OUT) variable 'a' at (1) is never set
---
Warning: ff.f90, line 11: INTENT(OUT) dummy argument A never set
---
fortcom: Warning: ff.f90, line 7: A dummy argument with an explicit INTENT(OUT)
declaration is not given an explicit value. [A]
subroutine sub(a)
---------------^
Test program:
-----------------
program test
implicit none
real :: a
call sub(a)
end program test
subroutine sub(a)
implicit none
real, intent(out) :: a
print *,a
end subroutine sub
-----------------
If you want, you can also -Wall warn that 'a' is used before it has gotten any
value assiged. (And Fortran does not guarantee for intent(out) that the
variable is set, even if I had add an a = 4.0 before the call sub(a).)
Actually, none of the other compilers detects this at compile time, at run time
NAG f95 (-nan or -C=undefined) does.
--
Summary: Warn if intent(out) dummy variable is not set
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tobias dot burnus at physik dot fu-berlin dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is not set
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
@ 2006-06-13 19:48 ` pault at gcc dot gnu dot org
2006-06-14 9:25 ` tobias dot burnus at physik dot fu-berlin dot de
` (8 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-06-13 19:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pault at gcc dot gnu dot org 2006-06-13 19:45 -------
Tobias,
I presented a patch for this problem and for detected unassigned r-values that
was rejected. I don't know what to say; I think that it's a bug, in principle,
but the standard does not require it.
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is not set
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
2006-06-13 19:48 ` [Bug fortran/28004] " pault at gcc dot gnu dot org
@ 2006-06-14 9:25 ` tobias dot burnus at physik dot fu-berlin dot de
2006-11-02 9:47 ` fxcoudert at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: tobias dot burnus at physik dot fu-berlin dot de @ 2006-06-14 9:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from tobias dot burnus at physik dot fu-berlin dot de 2006-06-14 09:17 -------
Paul,
> I presented a patch for this problem and for detected unassigned r-values that
> was rejected. I don't know what to say; I think that it's a bug, in principle,
> but the standard does not require it.
Well, that was the reason why one should only warn. But I think it is bad
enough to valid a default warning (as the other compilers have). But I'm also
fine with -Wall.
Tobias
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is not set
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
2006-06-13 19:48 ` [Bug fortran/28004] " pault at gcc dot gnu dot org
2006-06-14 9:25 ` tobias dot burnus at physik dot fu-berlin dot de
@ 2006-11-02 9:47 ` fxcoudert at gcc dot gnu dot org
2006-11-03 19:59 ` burnus at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-11-02 9:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from fxcoudert at gcc dot gnu dot org 2006-11-02 09:47 -------
(In reply to comment #1)
> I presented a patch for this problem and for detected unassigned r-values that
> was rejected. I don't know what to say; I think that it's a bug, in principle,
> but the standard does not require it.
Paul,
I looked at that bug again but couldn't find the patch you proposed. I think we
should issue a warning but not an error, because you can write code that is
still valid:
logical function foo(a, x)
integer,intent(in) :: a
integer,intent(out) :: x
foo = .false.
if (a > 0) then
foo = .true.
x = a
end if
end function foo
program test
integer :: a, x
a = -1
if (foo (a,x)) print *, x
end program test
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-11-02 09:47:07
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is not set
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
` (2 preceding siblings ...)
2006-11-02 9:47 ` fxcoudert at gcc dot gnu dot org
@ 2006-11-03 19:59 ` burnus at gcc dot gnu dot org
2006-11-11 11:18 ` tkoenig at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu dot org @ 2006-11-03 19:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2006-11-03 19:59 -------
> I think we should issue a warning but not an error, because you can write code
> that is [...]
Note that you should use "contains" for the code otherwise "foo" is regarded as
real function and the program does not compile.
g95 actually gives only a warning if the variable is not set at all, it does
not give a warning, if it is only set in the if branch. So does ifort. (NAG f95
and sunf95 don't give any warning neither with assigning it in the if branch or
not assigning it at all.)
Using -Wall gfortran states that the variable "x" is not used, but a default
warning that "A dummy argument with an explicit INTENT(OUT) declaration is not
given an explicit value." is more helpful.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is not set
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
` (3 preceding siblings ...)
2006-11-03 19:59 ` burnus at gcc dot gnu dot org
@ 2006-11-11 11:18 ` tkoenig at gcc dot gnu dot org
2007-07-03 21:00 ` dfranke at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2006-11-11 11:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from tkoenig at gcc dot gnu dot org 2006-11-11 11:18 -------
Related (and maybe more relevant):
INTENT(OUT) variables become undefined on subroutine
or function entry. We should be able to warn if
they are used:
subroutine foo(a,b)
real, intent(out) :: a
real, intent(out) :: b
print *,a
b = a
end subroutine foo
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tkoenig at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is not set
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
` (4 preceding siblings ...)
2006-11-11 11:18 ` tkoenig at gcc dot gnu dot org
@ 2007-07-03 21:00 ` dfranke at gcc dot gnu dot org
2007-07-03 21:06 ` dfranke at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-07-03 21:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from dfranke at gcc dot gnu dot org 2007-07-03 21:00 -------
Mine.
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dfranke at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is not set
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
` (5 preceding siblings ...)
2007-07-03 21:00 ` dfranke at gcc dot gnu dot org
@ 2007-07-03 21:06 ` dfranke at gcc dot gnu dot org
2007-07-08 22:41 ` dfranke at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-07-03 21:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from dfranke at gcc dot gnu dot org 2007-07-03 21:06 -------
While I got the initially requested warning, ...
> INTENT(OUT) variables become undefined on subroutine
> or function entry. We should be able to warn if
> they are used:
... this seems to generally be the same problem as PR20520 (allocatable arrays
used uninitialized without a warning)?! Do we have any means to recognize this?
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |dfranke at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2006-11-02 09:47:07 |2007-07-03 21:06:36
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is not set
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
` (6 preceding siblings ...)
2007-07-03 21:06 ` dfranke at gcc dot gnu dot org
@ 2007-07-08 22:41 ` dfranke at gcc dot gnu dot org
2007-07-08 22:55 ` [Bug fortran/28004] Warn if intent(out) dummy variable is used before being defined dfranke at gcc dot gnu dot org
2007-07-09 12:57 ` dfranke at gcc dot gnu dot org
9 siblings, 0 replies; 12+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-07-08 22:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from dfranke at gcc dot gnu dot org 2007-07-08 22:41 -------
Subject: Bug 28004
Author: dfranke
Date: Sun Jul 8 22:41:35 2007
New Revision: 126471
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126471
Log:
gcc:
2007-07-08 Daniel Franke <franke.daniel@gmail.com>
* function.c (do_warn_unused_parameter): Do not warn if
TREE_NO_WARNING is set.
gcc/fortran:
2007-07-08 Daniel Franke <franke.daniel@gmail.com>
PR fortran/24784
PR fortran/28004
* trans-decl.c (generate_local_decl): Adjusted warning on unused
dummy arguments, tell middle-end not to emit additional warnings.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-decl.c
trunk/gcc/function.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is used before being defined
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
` (7 preceding siblings ...)
2007-07-08 22:41 ` dfranke at gcc dot gnu dot org
@ 2007-07-08 22:55 ` dfranke at gcc dot gnu dot org
2007-07-09 12:57 ` dfranke at gcc dot gnu dot org
9 siblings, 0 replies; 12+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-07-08 22:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from dfranke at gcc dot gnu dot org 2007-07-08 22:54 -------
Partially fixed (warn if unused and thus not set).
Changed summary to reflect the remaining task.
Unassigning myself.
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|dfranke at gcc dot gnu dot |unassigned at gcc dot gnu
|org |dot org
Status|ASSIGNED |NEW
Summary|Warn if intent(out) dummy |Warn if intent(out) dummy
|variable is not set |variable is used before
| |being defined
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is used before being defined
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
` (8 preceding siblings ...)
2007-07-08 22:55 ` [Bug fortran/28004] Warn if intent(out) dummy variable is used before being defined dfranke at gcc dot gnu dot org
@ 2007-07-09 12:57 ` dfranke at gcc dot gnu dot org
9 siblings, 0 replies; 12+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-07-09 12:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from dfranke at gcc dot gnu dot org 2007-07-09 12:56 -------
Related: PR31447 - "set intent(out) arguments to uninitialized"
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/28004] Warn if intent(out) dummy variable is used before being defined
[not found] <bug-28004-4@http.gcc.gnu.org/bugzilla/>
@ 2010-12-29 14:53 ` dfranke at gcc dot gnu.org
0 siblings, 0 replies; 12+ messages in thread
From: dfranke at gcc dot gnu.org @ 2010-12-29 14:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28004
--- Comment #11 from Daniel Franke <dfranke at gcc dot gnu.org> 2010-12-29 14:52:48 UTC ---
Also related: PR45619.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-12-29 14:53 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-12 20:18 [Bug fortran/28004] New: Warn if intent(out) dummy variable is not set tobias dot burnus at physik dot fu-berlin dot de
2006-06-13 19:48 ` [Bug fortran/28004] " pault at gcc dot gnu dot org
2006-06-14 9:25 ` tobias dot burnus at physik dot fu-berlin dot de
2006-11-02 9:47 ` fxcoudert at gcc dot gnu dot org
2006-11-03 19:59 ` burnus at gcc dot gnu dot org
2006-11-11 11:18 ` tkoenig at gcc dot gnu dot org
2007-07-03 21:00 ` dfranke at gcc dot gnu dot org
2007-07-03 21:06 ` dfranke at gcc dot gnu dot org
2007-07-08 22:41 ` dfranke at gcc dot gnu dot org
2007-07-08 22:55 ` [Bug fortran/28004] Warn if intent(out) dummy variable is used before being defined dfranke at gcc dot gnu dot org
2007-07-09 12:57 ` dfranke at gcc dot gnu dot org
[not found] <bug-28004-4@http.gcc.gnu.org/bugzilla/>
2010-12-29 14:53 ` dfranke 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).