public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30438]  New: Unused variable should raise warning with -Wunused
@ 2007-01-11 16:12 fxcoudert at gcc dot gnu dot org
  2007-01-12  6:35 ` [Bug fortran/30438] " fxcoudert at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-01-11 16:12 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1413 bytes --]

Just so that I don't forget, in the following code, t is set but never used:

  integer, parameter :: nconf = 4000, nmol = 300
  integer, parameter :: nhist = 200
  real, parameter :: delta = 0.05

  integer :: conf, i, cote, idO, idH1, idH2
  integer(kind=8) :: hist(2,2,nhist)
  real :: t, dist(2,3*nmol)

  open(10,file="e_dist.moy")
  open(20,file="cat_dist.moy")
  do conf = 1, nconf
    read(10,*) t, dist(1,:)
    read(20,*) t, dist(2,:)
    do i = 1, nmol
      if (dist(1,3*i-2) < dist(2,3*i-2)) then
        ! Côté électron
        cote = 1
      else
        ! Côté cation
        cote = 2
      end if
      idO  = 1 + int(dist(cote,3*i-2) / delta)
      idH1 = 1 + int(dist(cote,3*i-1) / delta)
      idH2 = 1 + int(dist(cote, 3*i ) / delta)

      if (idO <= nhist) hist(cote,1,idO) = hist(cote,1,idO) + 1_8
      if (idH1 <= nhist) hist(cote,2,idH1) = hist(cote,2,idH1) + 1_8
      if (idH2 <= nhist) hist(cote,2,idH2) = hist(cote,2,idH2) + 1_8
    end do
  end do
  close(10)
  close(20)

  end


-- 
           Summary: Unused variable should raise warning with -Wunused
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fxcoudert at gcc dot gnu dot org


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


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

* [Bug fortran/30438] Unused variable should raise warning with -Wunused
  2007-01-11 16:12 [Bug fortran/30438] New: Unused variable should raise warning with -Wunused fxcoudert at gcc dot gnu dot org
@ 2007-01-12  6:35 ` fxcoudert at gcc dot gnu dot org
  2007-01-14  5:09 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-01-12  6:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from fxcoudert at gcc dot gnu dot org  2007-01-12 06:35 -------
Simpler example:

  real :: t, dist

  t = 12
  dist = 5
  if (dist < 0) then
    print *, dist
  end if

  end


-- 


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


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

* [Bug fortran/30438] Unused variable should raise warning with -Wunused
  2007-01-11 16:12 [Bug fortran/30438] New: Unused variable should raise warning with -Wunused fxcoudert at gcc dot gnu dot org
  2007-01-12  6:35 ` [Bug fortran/30438] " fxcoudert at gcc dot gnu dot org
@ 2007-01-14  5:09 ` pinskia at gcc dot gnu dot org
  2007-01-15  9:15 ` aldot at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-01-14  5:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-01-14 05:09 -------
The variable is set but not read from.
There is another bug about this for the C/C++ front-ends and a new option for
this case instead of just using -Wunused.

I would considered t in comment #1 as being used as it is set.


-- 


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


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

* [Bug fortran/30438] Unused variable should raise warning with -Wunused
  2007-01-11 16:12 [Bug fortran/30438] New: Unused variable should raise warning with -Wunused fxcoudert at gcc dot gnu dot org
  2007-01-12  6:35 ` [Bug fortran/30438] " fxcoudert at gcc dot gnu dot org
  2007-01-14  5:09 ` pinskia at gcc dot gnu dot org
@ 2007-01-15  9:15 ` aldot at gcc dot gnu dot org
  2007-02-01 12:27 ` [Bug fortran/30438] Set but never used variable should raise warning fxcoudert at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: aldot at gcc dot gnu dot org @ 2007-01-15  9:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from aldot at gcc dot gnu dot org  2007-01-15 09:15 -------
(In reply to comment #2)
> The variable is set but not read from.
> There is another bug about this for the C/C++ front-ends and a new option for
> this case instead of just using -Wunused.
> 
> I would considered t in comment #1 as being used as it is set.

I'd prefer this to be diagnosed to be "set but never used" in Fortran and C
along the lines of the "value computed is not used" diagnostics that is emitted
in C.


-- 

aldot at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldot at gcc dot gnu dot org


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


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

* [Bug fortran/30438] Set but never used variable should raise warning
  2007-01-11 16:12 [Bug fortran/30438] New: Unused variable should raise warning with -Wunused fxcoudert at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-01-15  9:15 ` aldot at gcc dot gnu dot org
@ 2007-02-01 12:27 ` fxcoudert at gcc dot gnu dot org
  2007-12-14  9:11 ` aldot at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-02-01 12:27 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-02-01 12:26:47
               date|                            |
            Summary|Unused variable should raise|Set but never used variable
                   |warning with -Wunused       |should raise warning


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


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

* [Bug fortran/30438] Set but never used variable should raise warning
  2007-01-11 16:12 [Bug fortran/30438] New: Unused variable should raise warning with -Wunused fxcoudert at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-02-01 12:27 ` [Bug fortran/30438] Set but never used variable should raise warning fxcoudert at gcc dot gnu dot org
@ 2007-12-14  9:11 ` aldot at gcc dot gnu dot org
  2010-05-01 12:39 ` dfranke at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: aldot at gcc dot gnu dot org @ 2007-12-14  9:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from aldot at gcc dot gnu dot org  2007-12-14 09:11 -------
Abovementioned C PR is PR18624 .


-- 


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


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

* [Bug fortran/30438] Set but never used variable should raise warning
  2007-01-11 16:12 [Bug fortran/30438] New: Unused variable should raise warning with -Wunused fxcoudert at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-12-14  9:11 ` aldot at gcc dot gnu dot org
@ 2010-05-01 12:39 ` dfranke at gcc dot gnu dot org
  2010-05-01 14:25 ` dfranke at gcc dot gnu dot org
  2010-05-01 18:28 ` jakub at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2010-05-01 12:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dfranke at gcc dot gnu dot org  2010-05-01 12:39 -------
With gcc version 4.6.0 20100501 (experimental) (GCC)

$ cat unused.c
int main() {
  int i;
  i = 42;
  return 0;
}

$ gcc-svn -Wall unused.c
unused.c: In function 'main':
unused.c:2:7: warning: variable 'i' set but not used
[-Wunused-but-set-variable]

Gfortran does not issue any warning with a similar fortran testcase.


Strangely, grepping the sources for use of the flag
'warn_unused_but_set_variable', I only find:

$ grep -r warn_unused_but_set_variable *
ChangeLog:      * toplev.c (warn_unused_but_set_variable): Default to
warn_unused.
common.opt:Common Var(warn_unused_but_set_variable) Init(-1) Warning
toplev.c:  if (warn_unused_but_set_variable == -1)
toplev.c:    warn_unused_but_set_variable = warn_unused;

which is slightly less than expected - where/how is this flag used?!


-- 

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=30438


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

* [Bug fortran/30438] Set but never used variable should raise warning
  2007-01-11 16:12 [Bug fortran/30438] New: Unused variable should raise warning with -Wunused fxcoudert at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2010-05-01 12:39 ` dfranke at gcc dot gnu dot org
@ 2010-05-01 14:25 ` dfranke at gcc dot gnu dot org
  2010-05-01 18:28 ` jakub at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2010-05-01 14:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from dfranke at gcc dot gnu dot org  2010-05-01 14:25 -------
See also PR33884.


-- 


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


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

* [Bug fortran/30438] Set but never used variable should raise warning
  2007-01-11 16:12 [Bug fortran/30438] New: Unused variable should raise warning with -Wunused fxcoudert at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2010-05-01 14:25 ` dfranke at gcc dot gnu dot org
@ 2010-05-01 18:28 ` jakub at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-01 18:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2010-05-01 18:28 -------
You should grep for unused_but_set_, then you'll see also:
c-decl.c:    OPT_Wunused_but_set_variable,
c-decl.c:  if (warn_unused_but_set_parameter)
c-decl.c:      OPT_Wunused_but_set_parameter,

See http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158086


-- 


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


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

end of thread, other threads:[~2010-05-01 18:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-11 16:12 [Bug fortran/30438] New: Unused variable should raise warning with -Wunused fxcoudert at gcc dot gnu dot org
2007-01-12  6:35 ` [Bug fortran/30438] " fxcoudert at gcc dot gnu dot org
2007-01-14  5:09 ` pinskia at gcc dot gnu dot org
2007-01-15  9:15 ` aldot at gcc dot gnu dot org
2007-02-01 12:27 ` [Bug fortran/30438] Set but never used variable should raise warning fxcoudert at gcc dot gnu dot org
2007-12-14  9:11 ` aldot at gcc dot gnu dot org
2010-05-01 12:39 ` dfranke at gcc dot gnu dot org
2010-05-01 14:25 ` dfranke at gcc dot gnu dot org
2010-05-01 18:28 ` jakub at gcc dot gnu dot 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).